Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


api-channels

 
 
channels

index
streamtuner2/channels/__init__.py

# encoding: UTF-8
# api: streamtuner2
# type: class
# category: ui
# title: Channel plugins
# description: Base implementation for channels and feature plugins
# version: 1.7
# license: public domain
# author: mario
# url: http://fossil.include-once.org/streamtuner2/
# pack:
#    *.py
# config: -
# priority: core
#
GenericChannel implements the basic GUI functions and defines
# the default channel data structure. It implements fallback logic
# for all other channel implementations. Only `bookmarks` uses it
# directly.
#
# All other plugins don't have a pre-defined Notebook tab in the
# GtkBuilder description. They derive from ChannelPlugins therefore,
# which constructs and registers the required gtk widgets manually.

 
Package Contents

      

 
bookmarks
cachereset
configwin
continuous_record
delicast
dirble
dnd
exportcat
favicon
file
filter_bitrate
filtermusic
global_key
gtk_theme
history
housemixes
internet_radio
jamendo
links
listenlive
liveradio
magnatune
modarchive
myoggradio
oggicon
pluginmanager2
prefstore
publicradiofan
radiobrowser
radiolist
radionet
radionomy
radiosure
radiotray
rcast
reciva
record_stop
recordflags
reddit
scripts
search
shoutcast
somafm
specbuttons
streamedit
streamlicensing
streema
surfmusik
theme_installer
timer
tunein
tuner2
ubuntuusers
ui_cht
useragentswitcher
version_check
xiph
youtube

 
Classes

      

 
__builtin__.object
FeaturePlugin
GenericChannel
ChannelPlugin

 
class ChannelPlugin(GenericChannel)

   

# channel plugin without glade-pre-defined notebook tab
 
 
Method resolution order:
ChannelPlugin
GenericChannel
FeaturePlugin
__builtin__.object

Methods defined here:
gui(self, parent)

Data and other attributes defined here:

module = 'abstract'

Methods inherited from GenericChannel:

__init__(self, parent=None)
# constructor
cache(self)
# Read previous channel/stream data, if there's any
columns(self, entries=None)
# Just wraps uikit.columns() to retain liststore, rowmap and pix_entry
currentcat(self)
# Selected category (current state from Gtk TreeModel)
deleted_streams(self, new, old)
# Finds differences in new/old streamlist, marks deleted with flag
display_categories(self)
# Refresh category treeview
first_show(self)
# Display .current category, once notebook/channel tab is first opened
insert_rows(self, rows, y=None)
# Insert/append new station rows - used by importing/drag'n'drop plugins
iter_cats(self, name, model, iter)
# Iterate over children to find current category
load(self, category, force=False, y=None)
# Called on switching genre/category, or loading a genre for the first time.
# Either fetches new stream data, or displays list from cache.
model_iter(self)
# Return ListStore object and Iterator for currently selected row in gtk.TreeView station list
play(self)
# Invoke action.play() for current station.
# Can be overridden to provide channel-specific "play" alternative
postprocess(self, streams)
# Stream list cleanup - invoked directly after reload(),
# callbacks can remove entries, or just update fields.
postprocess_filter_homepage(self, row, channel)
# Deduce homepage URLs from title
# by looking for www.xyz.com domain names
postprocess_filter_required_fields(self, row, channel)
# Filter entries without title or url
prepare(self, streams)
# Prepare stream list for display (called immediataly before .columns() refreshing)
prepare_filter_icons(self, row)
# state icon: bookmark star, or deleted mark
progress(self, max, i=None)
# sets updating progress bar for .update_streams or .reload_categores
record(self)
# Start streamripper/youtube-dl/etc
reload(self)
# Reload current station list
reload_categories(self)
# Update categories, save, and display
reload_if_current(self, category)
# Update streams pane if currently selected (used by bookmarks.links channel)
row(self)
# Currently selected entry in stations list, return complete data dict
row_icon(self, gtkIcon='gtk-about')
# Inject status icon into currently selected row (used by main.bookmark() call)
rowno(self)
# Convert ListStore iter to row number
save(self)
# Store current streams data
select_current(self, name)
# Traverse category TreeModel to set current, expand parent nodes
selected(self, name='url')
# Fetches a single varname from currently selected station entry
stations(self)
# Get list of stations in current category
str_from_struct(self, d)
# Retrieve first list value, or key from dict (-- used to get first category on init)
switch(self)
update_datamap(self, search='name', title=None)
# Create private copy of .datamap and modify entries (title= rewrites)
update_streams_partially_done(self, entries)
# Called occasionally (by some plugins) while updating station list

Data descriptors inherited from GenericChannel:

current

Data and other attributes inherited from GenericChannel:
audioformat = 'audio/mpeg'
base_url = ''
categories = []
catmap = {}
datamap = ['', 20, ['state', <type 'str'>, 'pixbuf', {}], 'Genre', 65, ['genre', <type 'str'>, 't', {}], ['Station Title', 275, ['title', &lt;type 'str'&gt;, 'text', {'cell-background': 12, 'cell-background-set': 13, 'strikethrough': 11}]'Station Title', 275, ['title', <type 'str'>, 'text', {'cell-background': 12, 'cell-background-set': 13, 'strikethrough': 11}, 'favicon', <type 'gtk.gdk.Pixbuf'>, 'pixbuf', {}], 'Now Playing', 185, ['playing', <type 'str'>, 'text', {'strikethrough': 11}], 'Listeners', 45, ['listeners', <type 'int'>, 't', {'strikethrough': 11}], 'Bitrate', 35, ['bitrate', <type 'int'>, 't', {}], 'Homepage', 160, ['homepage', <type 'str'>, 't', {'underline': 10}], False, 25, ['url', <type 'str'>, 't', {'strikethrough': 11}], False, 20, ['format', <type 'str'>, None, {}], False, 0, ['favourite', <type 'bool'>, None, {}], False, 0, ['deleted', <type 'bool'>, None, {}], False, 0, ['search_col', <type 'str'>, None, {}], False, 0, ['search_set', <type 'bool'>, None, {}]]
empty_stub = [{'bitrate': 0, 'genre': './.', 'homepage': '', 'listeners': 0, 'playing': 'Try Channel<font color="#c040c0">\xe2\x86\x92</font>Reload Categories later..', 'state': 'gtk-dialog-error', 'title': 'No categories found (website error)', 'url': 'none:'}]{'bitrate': 0, 'genre': './.', 'homepage': '', 'listeners': 0, 'playing': 'Try Channel\xe2\x86\x92Reload Categories later..', 'state': 'gtk-dialog-error', 'title': 'No categories found (website error)', 'url': 'none:'}
fixed_size = 24, 24
gtk_cat = None
gtk_list = None
has_search = False
img_resize = None
listformat = 'pls'
ls = None
meta = {'config': []}
nothing_found = [{'bitrate': 0, 'genre': './.', 'listeners': 0, 'playing': 'Notice', 'state': 'gtk-no', 'title': 'No contents found on directory server'}]{'bitrate': 0, 'genre': './.', 'listeners': 0, 'playing': 'Notice', 'state': 'gtk-no', 'title': 'No contents found on directory server'}
pix_entry = None
placeholder = [{'bitrate': 0, 'genre': './.', 'homepage': '', 'listeners': 0, 'playing': './.', 'state': 'gtk-info', 'title': 'Subcategory placeholder', 'url': 'none:'}]{'bitrate': 0, 'genre': './.', 'homepage': '', 'listeners': 0, 'playing': './.', 'state': 'gtk-info', 'title': 'Subcategory placeholder', 'url': 'none:'}
postprocess_filters = []
prepare_filters = []
progress_state = 1
rowmap = []
rx_www_url = <_sre.SRE_Pattern object>
shown = None
streams = {}
titles = {}

Methods inherited from FeaturePlugin:

init2(self, parent, *k, **kw)
# optionally to be overriden by plugins (run after base __init__)
status(self, *args, **kw)
# Statusbar stub (defers to parent/main window, if in GUI mode)
warn(self, text, *args, **kw)
# Statusbar with highlighting and default icon

Data descriptors inherited from FeaturePlugin:

__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from FeaturePlugin:
parent = None

 
class FeaturePlugin(__builtin__.object)

   

# Base class for plugins (features or channels)
 
  Methods defined here:
__init__(self, parent, *k, **kw)
# minimum setup for ChannelPlugins and feature hooks
init2(self, parent, *k, **kw)
# optionally to be overriden by plugins (run after base __init__)
status(self, *args, **kw)
# Statusbar stub (defers to parent/main window, if in GUI mode)
warn(self, text, *args, **kw)
# Statusbar with highlighting and default icon

Data descriptors defined here:

__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
meta = {'config': []}
module = ''
parent = None

 
class GenericChannel(FeaturePlugin)

   

# Generic channel module
 
 
Method resolution order:
GenericChannel
FeaturePlugin
__builtin__.object

Methods defined here:
__init__(self, parent=None)
# constructor
cache(self)
# Read previous channel/stream data, if there's any
columns(self, entries=None)
# Just wraps uikit.columns() to retain liststore, rowmap and pix_entry
currentcat(self)
# Selected category (current state from Gtk TreeModel)
deleted_streams(self, new, old)
# Finds differences in new/old streamlist, marks deleted with flag
display_categories(self)
# Refresh category treeview
first_show(self)
# Display .current category, once notebook/channel tab is first opened
gui(self, parent)
# initialize Gtk widgets / data objects
insert_rows(self, rows, y=None)
# Insert/append new station rows - used by importing/drag'n'drop plugins
iter_cats(self, name, model, iter)
# Iterate over children to find current category
load(self, category, force=False, y=None)
# Called on switching genre/category, or loading a genre for the first time.
# Either fetches new stream data, or displays list from cache.
model_iter(self)
# Return ListStore object and Iterator for currently selected row in gtk.TreeView station list
play(self)
# Invoke action.play() for current station.
# Can be overridden to provide channel-specific "play" alternative
postprocess(self, streams)
# Stream list cleanup - invoked directly after reload(),
# callbacks can remove entries, or just update fields.
postprocess_filter_homepage(self, row, channel)
# Deduce homepage URLs from title
# by looking for www.xyz.com domain names
postprocess_filter_required_fields(self, row, channel)
# Filter entries without title or url
prepare(self, streams)
# Prepare stream list for display (called immediataly before .columns() refreshing)
prepare_filter_icons(self, row)
# state icon: bookmark star, or deleted mark
progress(self, max, i=None)
# sets updating progress bar for .update_streams or .reload_categores
record(self)
# Start streamripper/youtube-dl/etc
reload(self)
# Reload current station list
reload_categories(self)
# Update categories, save, and display
reload_if_current(self, category)
# Update streams pane if currently selected (used by bookmarks.links channel)
row(self)
# Currently selected entry in stations list, return complete data dict
row_icon(self, gtkIcon='gtk-about')
# Inject status icon into currently selected row (used by main.bookmark() call)
rowno(self)
# Convert ListStore iter to row number
save(self)
# Store current streams data
select_current(self, name)
# Traverse category TreeModel to set current, expand parent nodes
selected(self, name='url')
# Fetches a single varname from currently selected station entry
stations(self)
# Get list of stations in current category
str_from_struct(self, d)
# Retrieve first list value, or key from dict (-- used to get first category on init)
switch(self)
update_datamap(self, search='name', title=None)
# Create private copy of .datamap and modify entries (title= rewrites)
update_streams_partially_done(self, entries)
# Called occasionally (by some plugins) while updating station list

Data descriptors defined here:

current

Data and other attributes defined here:
audioformat = 'audio/mpeg'
base_url = ''
categories = []
catmap = {}
datamap = ['', 20, ['state', <type 'str'>, 'pixbuf', {}], 'Genre', 65, ['genre', <type 'str'>, 't', {}], ['Station Title', 275, ['title', &lt;type 'str'&gt;, 'text', {'cell-background': 12, 'cell-background-set': 13, 'strikethrough': 11}]'Station Title', 275, ['title', <type 'str'>, 'text', {'cell-background': 12, 'cell-background-set': 13, 'strikethrough': 11}, 'favicon', <type 'gtk.gdk.Pixbuf'>, 'pixbuf', {}], 'Now Playing', 185, ['playing', <type 'str'>, 'text', {'strikethrough': 11}], 'Listeners', 45, ['listeners', <type 'int'>, 't', {'strikethrough': 11}], 'Bitrate', 35, ['bitrate', <type 'int'>, 't', {}], 'Homepage', 160, ['homepage', <type 'str'>, 't', {'underline': 10}], False, 25, ['url', <type 'str'>, 't', {'strikethrough': 11}], False, 20, ['format', <type 'str'>, None, {}], False, 0, ['favourite', <type 'bool'>, None, {}], False, 0, ['deleted', <type 'bool'>, None, {}], False, 0, ['search_col', <type 'str'>, None, {}], False, 0, ['search_set', <type 'bool'>, None, {}]]
empty_stub = [{'bitrate': 0, 'genre': './.', 'homepage': '', 'listeners': 0, 'playing': 'Try Channel<font color="#c040c0">\xe2\x86\x92</font>Reload Categories later..', 'state': 'gtk-dialog-error', 'title': 'No categories found (website error)', 'url': 'none:'}]{'bitrate': 0, 'genre': './.', 'homepage': '', 'listeners': 0, 'playing': 'Try Channel\xe2\x86\x92Reload Categories later..', 'state': 'gtk-dialog-error', 'title': 'No categories found (website error)', 'url': 'none:'}
fixed_size = 24, 24
gtk_cat = None
gtk_list = None
has_search = False
img_resize = None
listformat = 'pls'
ls = None
meta = {'config': []}
nothing_found = [{'bitrate': 0, 'genre': './.', 'listeners': 0, 'playing': 'Notice', 'state': 'gtk-no', 'title': 'No contents found on directory server'}]{'bitrate': 0, 'genre': './.', 'listeners': 0, 'playing': 'Notice', 'state': 'gtk-no', 'title': 'No contents found on directory server'}
pix_entry = None
placeholder = [{'bitrate': 0, 'genre': './.', 'homepage': '', 'listeners': 0, 'playing': './.', 'state': 'gtk-info', 'title': 'Subcategory placeholder', 'url': 'none:'}]{'bitrate': 0, 'genre': './.', 'homepage': '', 'listeners': 0, 'playing': './.', 'state': 'gtk-info', 'title': 'Subcategory placeholder', 'url': 'none:'}
postprocess_filters = []
prepare_filters = []
progress_state = 1
rowmap = []
rx_www_url = <_sre.SRE_Pattern object>
shown = None
streams = {}
titles = {}

Methods inherited from FeaturePlugin:

init2(self, parent, *k, **kw)
# optionally to be overriden by plugins (run after base __init__)
status(self, *args, **kw)
# Statusbar stub (defers to parent/main window, if in GUI mode)
warn(self, text, *args, **kw)
# Statusbar with highlighting and default icon

Data descriptors inherited from FeaturePlugin:

__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from FeaturePlugin:
module = ''
parent = None

 
Functions

      

 
entity_decode(str)
# remove SGML/XML entities
mime_fmt(s)
# Convert audio format nick/shortnames to mime types, e.g. "OGG" to "audio/ogg"
# (only used by few plugin meanwhile, could be merged with action. module now)
nl(str)
strip_tags(s)
# Strip html <tags> from string
stub_parent(object)
# WORKAROUND for direct channel module imports,
# eases instantiations without GUI a little,
# reducing module dependencies (conf. / ahttp. / channels. / parent.) would be better
to_int(s)
# Extracts integer from string
unhtml(str)
# Combine html tag, escapes and whitespace cleanup
use_rx(func)
# Decorator

 
Data

      

  __all__ = ['FeaturePlugin', 'GenericChannel', 'ChannelPlugin', 'use_rx', 'mime_fmt', 'stub_parent', 'entity_decode', 'strip_tags', 'nl', 'unhtml', 'to_int']'FeaturePlugin', 'GenericChannel', 'ChannelPlugin', 'use_rx', 'mime_fmt', 'stub_parent', 'entity_decode', 'strip_tags', 'nl', 'unhtml', 'to_int'