daily_browsing

daily browsing

version 0.95 beta, 2014-10-28

introduction:

daily_browsing.py will start a bunch of urls in your default browser, subject to rules governing whether they run at the time and on the day you run the script (the “constraints”).

You provide a configuration file that specifies the urls you want to open, the time constraints for each, and the delay before the next url in your list opens.

Your browser doesn’t have to be running; the script will start it if required.

installation:

daily_browsing.zip (for windows) and daily_browsing.tar.gz (for linux, mac) each include the following files:

daily_browsing.py requires python 2.6.5 or later.

Most linux distros and Macs probably have python 2.7.x installed, but on windows you’ll probably have to install it.

Tested on ubuntu, windows, and mac.

daily_browsing.py3 works with python 3.x.

install.py creates a configuration directory and copies a sample configuration file (daily_browsing.conf) and some html files to it.

on windows, installs to the directory %USERPROFILE\.daily_browsing

on linux and mac installs to the directory $HOME/.daily_browsing

If files with the same name but different contents already exist in the destination folder, they will be renamed before new files are copied in.

It remains for you to place the script daily_browsing.py or daily_browsing.py3 where you want it and to create a launcher/icon shortcut or hotkey/keyboard shortcut for it.

On linux, a launcher or keyboard shortcut to

<full path to>/daily_browsing.py

will do.

On windows you'll want a shortcut to

<full path to>\pythhonw.exe <full path to>\daily_browsing.py

If you’re not using daily_browsing.conf as a configuration file, or your configuration file isn’t in the creates a normal location, you’ll need to add a parameter identifying what file you’re using and (if not in the expected folder), where it is.

uninstall.py removes the directory created by install.sh and all its contents.

usage:

To verify your configuration file is working as you want, in a console window execute the line you’ll be using as your shortcut or launcher.

options:

The following are used on their own, without a configuration file argument:

--version

-h

--help

Show program’s version number, then exit.

If present everything else on the command line is ignored, except --help, which takes precedence.

Show a help message, then exit.

If present everything else on the command line is ignored.

The behaviour of daily_browsing.py is defined in a configuration file, sample (daily_browsing.conf) included.

If the command line argument <path to configuration file> isn’t provided, or a relative path is used, looks for daily_browsing.conf:

on windows, in the directory %USERPROFILE\.daily_browsing;

if not found there looks in %USERPROFILE;

if not found there looks for the script in %ALLUSERSPROFILE\.daily_browsing;

if not found there looks in %ALLUSERSPROFILE

on linux and mac looks for the script in $HOME/.daily_browsing;

if not found there looks in $HOME

if not found there, looks for the script in folder in which daily_browsing.py is running.

configuration file format:

Lines in a configuration file beginning with # are treated as a comment and ignored, as is any text after a trailing # on a line starting with a url.

Each line in a configuration file can be a:

url line

default line

variable line

macro line

Each line may be terminated with ‘#’ followed by a comment.

url lines:

url [property [property [property ...]]]

The first field (url) is required; properties are optional, can be in any order and are separated by whitespace.

url:

A url can be pretty much any link that will work in your browser. Local files can be specified in the format you would expect to see in your browser’s link bar

(e.g. file:///C:/full/path//to/something.html).

You can also use a local file path, as you would see in your file browser.

A relative local file path will be taken relative to the location of your <configuration file>.

In particular you can use done.html in the same folder as your <configuration file> to announce that the last link in your set has been loaded.

properties:

property := tagged_property | untagged_property

tagged_property := TIME:time_period | HOUR:hour | DOW:day_of_week | MONTH:month | DIM:day_of_month | WIY:week_in_year | DIY:day_in_year | DELAY:display_delay

Tags are case insensitive.

A tag and colon can be followed by nothing. That undoes the effect of any default property of the same type in force.

untagged_property := time_period | day_of_week | month | display_delay

There must be no whitespace anywhere within a property; in particular no whitespace around the colon separating a tag from the property’s value.

You can have at most one property of each type on a url line.

All properties except display_delay are constraints.

A constraint is a list of one or more periods during which the url is meant to be displayed.

A period can be a single value (“Sunday”, “February”, “HOUR:10”) but is more typically a range of values (“Sat-Sun”, “Jan-June”, “1000-1500”, “HOUR:17-”).

Multiple periods are separated by commas, so a constraints can look like “Sat-Sun,Wed” or “1100-1300,1500-1800”

.

exclusions:

Any period within a property, tagged or untagged (other than display_delay) can be preceded by a tilda (‘~’), indicating the period is to be excluded from the set established by defaults or preceding periods within the same property.

If you exclude a property period, and it's the first period specified (either by default, or within the current property), it will be assumed to be a exclusion from all possible values of the property (so e.g. for a time_period, from 0000-2359).

So “DOW:~Sun” on its own means “include all days of the week but Sunday”

If some of the excluded period falls outside all periods previously specified (either by default, or within the current property), the portion of the excluded period outside periods already specified will be ignored (So “TIME:~1100-1300” would be valid with a default of “AM”, but the bit after noon would have no effect).

If all of an excluded period falls outside all periods previously specified, the exclusion is redundant, which is an error; you’ll get a message.

additions:

A property on a url line normally overrides the same property specified as a default.

Preceding a tagged or untagged property (other than display_delay) with a plus (‘+’), will cause it to be added to the default of the same type rather than overriding it.

So “DOW:Sat” on a url line will override a default of “DOW:Sun”; but “+DOW:Sat” on a url line will add to a default of “DOW:Sun”.

These are the properties that can appear on a url or default line:

display_delay:

delay_in_secs, on its own.

Or tagged syntax:

DELAY:delay_in_secs

delay_in_secs can be no more than two digits. An integer time, in seconds, to wait before next link is launched.

All other properties are constraints: they specify times and days during which a url should be displayed.

If there are no constraints, a url will be displayed whenever daily_browsing.py is run.

If there is more than one constraint for a url, all have to be satisfied at the moment daily_browsing.py is run for the url to be displayed.

constraints on time

TIME and HOUR limit the time of day during which the url will appear; all other constraints limit the days on which it may appear.

time_period:

[+]time_period_set

Tagged syntax:

[+]TIME:[time_period_set]

[+]TIMES:[time_period_set]

[+]T:[time_period_set]

time_period_set := [~]time_period[,[~]time_period[,[~]time_period...]]

time_period := ‘am’ | ‘pm’ | –time_end | time_start– | time_starttime_end

There must be no whitespace within a time_period_set, or between a time_period_set and TIME:.

time_start, time_end:

24-hour clock time. Four digits are recommended, although three will be understood.

If the current time falls before time_start or after time_end, the url not displayed

Hyphens must _not_ be separated from the time_start and or time_end they modify.

hour:

Only expressed in tagged syntax:

[+]HOUR:[hours]

[+]HR:[hours]

[+]H:[hours]

hours := [~]hour_set[,[~]hour_set[, ...]]

hour_set := ‘am’ | ‘pm’ | ‘o’ | ‘odd’ | ‘e’ | ‘even‘ | hour | hour_starthour_end | –hour_end | hour_start

hour, hour_start and hour_end can be 0 through 23

‘o’ or ‘odd’ produces a list of all odd hours in a day, ‘e’ or ‘even‘ of all even hours. All text is case insensitive.

There must be no whitespace within a hour_set, or between an hour_set and HOUR:.

Each hour property is expanded into a time_period property; e.g. hour 13 becomes 1300-1359.

So an hours property will override or add to a time_period or hour property previously defined on the same line or as a default;

hour exclusions will exclude from already-specified time_period or hour properties or defaults.

constraints on days

The remaining constraints determine whether a url will be displayed on a particular day, should daily_browsing.py be run then.

Since all constraints have to be fulfilled for a url to be displayed, it's possible to come up with day constraints that will never allow a url to show

(e.g. Month:Jan DIY:200-300). If you provide such a set of properties, daily_browsing.py will provide an error message.

day_of_week:

[+]list_of_days

Tagged syntax:

[+]DOW:[list_of_days]

[+]W:[list_of_days]

list_of_days := [~]day_set[,[~]day_set[,...]]

day_set := day | day_startday_end | –day_end | day_start

day, day_start and day_end can be a string beginning with the first two letters of a weekday name.

In tagged format, can be 1 through 6 (1 for Monday)

In tagged format, can also be ‘o’, ‘odd’, ‘e’ or ‘even‘ (all case insensitive);

‘o’ or ‘odd’ produce ”Mon,Wed,Fri,Sun”; ‘e’ or ‘even‘ produce “Tue,Thu,Sat”.

There must be no whitespace within a list_of_days, or between a list_of_days and DOW:

months:

[+]list_of_months

Tagged syntax:

[+]MONTHS:[list_of_months]

[+]MONTH:[list_of_months]

[+]MOS:[list_of_months]

[+]MO:[list_of_months]

[+]M:[list_of_months]

list_of_months := [~]month_set[,[~]month_set[,...]]

month_set := month | month_startmonth_end | –month_end | month_start

month, month_start and month_end can be a string beginning with the first three letters of a month name.

In tagged format, can also be 1 through 12 (1 for January).

In tagged format, can also be ‘o’, ‘odd’, ‘e’ or ‘even‘ (all case insensitive);

‘o’ or ‘odd’ produces “Jan,Mar,May,Jul,Sep,Nov”; ‘e’ or ‘even‘ produce “Feb,Apr,Jun,Aug,Oct,Dec”.

There must be no whitespace within a month_set, or between a month_set and MONTHS:.

day_of_month:

Only expressed in tagged syntax:

[+]DOM:[list_of_days]

list_of_days := [~]day_set[,[~]day_set[,...]]

day_set := ‘o’ | ‘odd’ | ‘e’ | ‘even‘ | day | day_startday_end | –day_end | day_start

day, day_start and day_end can be 1 through 31

‘o’ produces a list of all odd days in a month, ‘e’ of all even days. All text is case insensitive.

There must be no whitespace within day_of_month, or between a day_of_month and DIM:.

day_in_year:

Only expressed in tagged syntax:

[+]DIY:[list_of_days]

list_of_days := [~]day_set[,[~]day_set[,...]]

day_set := ‘o’ | ‘odd’ | ‘e’ | ‘even‘ | day | day_startday_end | –day_end | day_start

day, day_start and day_end can be 1 through 366

‘o’ produces a list of all odd days in a year, ‘e’ of all even days. All text is case insensitive.

There must be no whitespace within day_in_year, or between a day_in_year and DIY:.

week_in_year:

Only expressed in tagged syntax:

[+]WIY:[list_of_weeks]

list_of_weeks := [~]week_set[,[~]week_set[,...]]

week_set := ‘o’ | ‘odd’ | ‘e’ | ‘even‘ | week | week_startweek_end | –week_end | week_start

day, week_start and week_end can be 1 through 52

‘o’ produces a list of all odd weeks, ‘e’ of all even weeks in a year. All text is case insensitive.

There must be no whitespace within week_in_year, or between a week_in_year and WIY:.

default lines:

[‘default’ | ‘defaults’] [property [property [property ...]]]

If a line begins with ‘default’ (case-insensitive), all fields on that line set default values for all url lines that follow.

A line with just properties on it has the same effect.

You can have at most one property of each type on a default line.

A default remains in force until the end of the configuration file, or until the next ‘default’ line with the same field.

You can revert to daily_browsing default for a field with a tag with nothing after the colon e.g. TIME:.

You can revert to daily_browsing default for all fields by using the the word ‘reset’ on a default line

(which means a line containing just the word ‘reset’ will do the job).

On a url line you can temporarily revert to daily_browsing defaults by using the the word ‘reset’.

variable lines:

variable = value

The configuration file can include variables.

A variable may appear at any point in the configuration file; every time it occurs its new value applies from that point in the file onward.

Valid variables are:

(note 1) console_output can be ‘normal’, ‘verbose’, (synonyms ‘full’, ‘more’) or ‘quiet’, (synonym ‘less’).

(note 2) browser may be any of: ‘mozilla’, ‘firefox’, ‘netscape’, ‘opera’, ‘galeon’, ‘windows-default’, ‘macosx’, ‘safari’, ‘epiphany’, ‘skipstone’, ‘kfmclient’, ‘konqueror’, ‘kfm’, ‘mosaic’, ‘grail’, ‘links’, ‘elinks’, ‘lynx’ or ‘w3m’. Unfortunately ‘chrome’ is not available (unless either chrome is your default browser or you use the python3 version of the script). An empty value (“browser = ”) means use the default browser.

(note 3) In a console/terminal, especially if console_output is ‘verbose’, output will be untidy unless urls are truncated (allowing room for messages abut which constraint came into effect, what properties were on the line, etc) the url_length variable specifies the length to which urls will be truncated. They will be made longer if that’s necessary to distinguish urls from each other. In a wider console a larger url_length can make output more comprehensible. Can be zero or any positive integer. Zero means not to truncate at all.

(note 4) on_end may be any of:

If you want different responses at the end of a run depending on time constraints, you'll have to set on_end to “none” and provide different (local file?) urls with different time constraints, e.g.

done_am.html AM

done_pm.html PM

macro lines:

macro = value

The configuration file can include macro definitions.

A macro_name can be any string four characters or more in length made up of alphabetic characters and the underscore and not one of the variable names.

Once a macro_name is defined, if macro_name occurs on a url line, it’s replaced with the value associated with it.

If value is the null string, it will undefine the macro_name if it’s been previously defined.

alternatives:

tips:

One possible use of display_delays is to set it high enough for pages that only need a quick glance (weather? one-page comics?) so that the page can load and you can read it and even close it before the next page comes up.

Another possibility is to get all pages to load while you're doing something else, possible on another page in the same browser. In firefox, you can make that happen using the extension Tab mix plus. On its Events tab, tab opening sub-tab, go to the ‘focus/select tabs that open from’ section and uncheck ‘other applications’.

Latest version (0.95 beta) of daily_browsing: zip file (for windows), tar.gz file (for linux, mac).

Back to top

Back to home