Controller
Basic Controllers
- class controllers.root.RootController(session, path='')[source]
Bases:
BaseController
Root Web Controller
- class controllers.base.BaseController(path='', **kwargs)[source]
Bases:
Resource
Web Base Controller
- __init__(path='', **kwargs)[source]
- Args:
path: Base path
session: (?) Session instance
withMainTemplate: (?)
isJson: responses shall be JSON encoded
isCustom: (?)
isGZ: responses shall be GZIP compressed
isImage: (?) responses shall image
- error404(request)[source]
Perform HTTP Error 404
- Args:
request (twisted.web.server.Request): HTTP request object
- getChild(path, request)[source]
Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
- render(request)[source]
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- controllers.utilities.NS = {'DVB-C': 4294901760, 'DVB-T': 4008574976}
Label:Namespace map
- controllers.utilities.NS_DVB_C = 4294901760
Namespace - DVB-C services
- controllers.utilities.NS_DVB_T = 4008574976
Namespace - DVB-T services
- controllers.utilities.NS_LOOKUP = {4008574976: 'DVB-T', 4294901760: 'DVB-C'}
Namespace:Label lookup map
- controllers.utilities.create_servicereference(*args, **kwargs)[source]
Generate a (Enigma2 style) service reference string representation.
- Parameters:
args[0] (
dict
) – Service Reference Parameter as dictservice_type (int) – Service Type
sid (int) – SID
tsid (int) – TSID
oid (int) – OID
ns (int) – Enigma2 Namespace
- controllers.utilities.get_config_attribute(path, root_obj, head=None)[source]
Determine attribute of root_obj to be accessed by path in a (somewhat) safe manner. This implementation will allow key and index based accessing too (e.g.
config.some_list[0]
orconfig.some_dict['some_key']
) The path value needs to start with head (default=’config’).- Args:
path: character string specifying which attribute is to be accessed root_obj: An object whose attributes are to be accessed. head: Value of the first portion of path
- Returns:
Attribute of root_obj
- Raises:
ValueError: If path is invalid. AttributeError: If attribute cannot be accessed
- controllers.utilities.lenient_decode(value, encoding=None)[source]
Decode an encoded string and convert it to an unicode string.
- Args:
value: input value encoding: string encoding, defaults to utf-8
- Returns:
(unicode) decoded value
>>> lenient_decode("Hallo") u'Hallo' >>> lenient_decode(u"Hallo") u'Hallo' >>> lenient_decode("HällöÜ") u'H\xe4ll\xf6\xdc'
- controllers.utilities.lenient_force_utf_8(value)[source]
- Args:
value: input value
- Returns:
(basestring) utf-8 encoded value
>>> isinstance(lenient_force_utf_8(''), basestring) True >>> lenient_force_utf_8(u"Hallo") 'Hallo' >>> lenient_force_utf_8("HällöÜ") 'H\xc3\xa4ll\xc3\xb6\xc3\x9c'
- controllers.utilities.parse_servicereference(serviceref)[source]
Parse a Enigma2 style service reference string representation.
- Parameters:
serviceref (string) – Enigma2 style service reference
>>> sref = '1:0:1:300:7:85:00c00000:0:0:0:' >>> result = parse_servicereference(sref) >>> result {'service_type': 1, 'oid': 133, 'tsid': 7, 'ns': 12582912, 'sid': 768} >>> sref_g = create_servicereference(**result) >>> sref_g '1:0:1:300:7:85:00c00000:0:0:0:' >>> sref_g2 = create_servicereference(result) >>> sref_g2 '1:0:1:300:7:85:00c00000:0:0:0:' >>> sref == sref_g True >>> sref2 = '1:64:A:0:0:0:0:0:0:0::SKY Sport' >>> result2 = parse_servicereference(sref2) >>> result2 {'service_type': 10, 'oid': 0, 'tsid': 0, 'ns': 0, 'sid': 0} >>> sref3 = '1:0:0:0:0:0:0:0:0:0:/media/hdd/movie/20170921 2055 - DASDING - DASDING Sprechstunde - .ts' >>> result3 = parse_servicereference(sref3) >>> result3 {'service_type': 0, 'oid': 0, 'tsid': 0, 'ns': 0, 'sid': 0}
Web Controllers
- class controllers.web.ApiController(session, path='')[source]
Bases:
WebController
- class controllers.web.WebController(session, path='')[source]
Bases:
BaseController
HTTP Web Controller
Fork of Enigma2 WebInterface API as described in e.g. https://dream.reichholf.net/e2web/.
- P_about(request)[source]
Request handler for the about endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_addlocation(request)[source]
Request handler for the addlocation endpoint. Add a path to the list of paths where video files are stored.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_bouquets(request)[source]
Request handler for the boquets endpoint. Get list of tuples (bouquet reference, bouquet name) for available bouquets.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_currenttime(request)[source]
Request handler for the currenttime endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_deviceinfo(request)[source]
Request handler for the deviceinfo endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_epgmulti(request)[source]
Request handler for the epgmulti endpoint.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_epgsearch(request)[source]
EPG event search and lookup handler.
Note
One may use
controllers.events.EventsController.search()
for searching events.- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_epgxmltv(request)[source]
Request handler for the epgxmltv endpoint.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object bRef: mandatory, method uses epgmulti lang: mandatory, needed for xmltv and Enigma2 has no parameter for epg language
- Returns:
HTTP response with headers
- P_external(request)[source]
Request handler for the external endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_getallservices(request)[source]
Request handler for the getallservices endpoint. Retrieve list of services in bouquets.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_getaudiotracks(request)[source]
Request handler for the /getaudiotracks endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_getcurrent(request)[source]
Request handler for the getcurrent endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/getcurrent
- P_getcurrlocation(request)[source]
Request handler for the getcurrlocation endpoint. Get currently selected path where video files are to be stored.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_getlocations(request)[source]
Request handler for the getlocations endpoint. Retrieve paths where video files are stored.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_getpicon(request)[source]
Get the picon from service.
- GET /api/getpicon
- Query Parameters:
sRef (string) – service refrerence
path (string) – path of the picons
json (string) – result as json
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_getpid(request)[source]
Request handler for the getpid endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_getserviceref(request)[source]
Get the serviceref from name.
- GET /api/getserviceref
- Query Parameters:
name (string) – service name to find
searchinBouquetsOnly (string) – must be ‘true’
bRef (string) – define only one single bouquet where to find
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_getservices(request)[source]
Request handler for the getservices endpoint. Retrieve list of bouquets.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_getsubtitles(request)[source]
Request handler for the getsubtitles endpoint.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_gettags(request)[source]
Request handler for the gettags endpoint. Get tags of movie file (?).
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_loadepg(request)[source]
Request handler for the loadepg endpoint.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_message(request)[source]
Request handler for the message endpoint. Display a message on the screen attached to enigma2 device.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_messageanswer(request)[source]
Request handler for the messageanswer endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_moviecopy(request)[source]
Request handler for the moviecopy endpoint. Copy movie file.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_moviedelete(request)[source]
Request handler for the moviedelete endpoint. Delete movie file.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_moviedetails(request)[source]
Request handler for the movie endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_movieinfo(request)[source]
Request handler for the movie endpoint. Add/Remove tags to movie file. Multiple tags needs to separate by , Remame title of movie. Get/set movie cuts.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_movielist(request)[source]
Request handler for the movielist endpoint. Retrieve list of movie items. (alternative implementation)
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_movielisthtml(request)[source]
Request handler for the movielisthtml endpoint. Retrieve list of movie items in HTML format.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_movielistm3u(request)[source]
Request handler for the movielistm3u endpoint. Retrieve list of movie items in M3U format.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_movielistrss(request)[source]
Request handler for the movielistrss endpoint. Retrieve list of movie items in RSS format.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_moviemove(request)[source]
Request handler for the moviemove endpoint. Move movie file.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_movierename(request)[source]
Request handler for the movierename endpoint. Rename movie file.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_movietags(request)[source]
Request handler for the movietags endpoint. Add/Remove tags to movie file.
DEPRECATED -> use movieinfo instead
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_parentcontrollist(request)[source]
Request handler for the parentcontrollist endpoint.
See also
https://github.com/oe-alliance/OpenWebif/wiki/OpenWebif-API-documentation#parentcontrollist
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_pluginlistread(request)[source]
Request handler for the pluginlistread endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_powerstate(request)[source]
Request handler for the powerstate endpoint. Get/set power state of enigma2 device.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_recordnow(request)[source]
Request handler for the recordnow endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_remotecontrol(request)[source]
Request handler for the remotecontrol endpoint. Send remote control codes.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_removelocation(request)[source]
Request handler for the removelocation endpoint. Remove a path from the list of paths where video files are stored.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_restarttwisted(request)[source]
Request handler for the restarttwisted endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_saveconfig(request)[source]
Request handler for the saveconfig endpoint.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- POST /web/saveconfig
- Query Parameters:
key (string) – configuration key
value (string) – configuration value
- P_saveepg(request)[source]
Request handler for the saveepg endpoint.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_selectaudiotrack(request)[source]
Request handler for the /selectaudiotrack endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/signal
- Query Parameters:
id (int) – audio track ID
- P_servicelistplayable(request)[source]
Request handler for the servicelistplayable endpoint. Retrieve list of ‘playable’ bouquets.
See also
https://github.com/oe-alliance/OpenWebif/wiki/OpenWebif-API-documentation#servicelistplayable
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_servicelistreload(request)[source]
Reload service lists, transponders, parental control black-/white lists or/and lamedb.
See also
https://github.com/oe-alliance/OpenWebif/wiki/OpenWebif-API-documentation#servicelistreload
- GET /web/servicelistreload
- Query Parameters:
mode (string) – [0=both, 1=lamedb only, 2=userbouqets only, 3=transponders, 4=parentalcontrol white-/blacklist]
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_serviceplayable(request)[source]
Request handler for the serviceplayable endpoint. Check if referenced service is ‘playable’.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_servicesm3u(request)[source]
Request handler for the servicesm3u endpoint. Retrieve list of bouquets(?) in M3U format.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/services.m3u
- Query Parameters:
bRef (string) – bouquet reference
- P_servicesxspf(request)[source]
Request handler for the servicesxspf endpoint. Retrieve list of bouquets(?) in XSPF format.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/services.xspf
- Query Parameters:
bRef (string) – bouquet reference
- P_set_powerup_without_waking_tv(request)[source]
Request handler for the set_powerup_without_waking_tv endpoint. Mark ‘powerup without waking TV’ being available.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_settings(request)[source]
Request handler for the settings endpoint. Retrieve list of key/kalue pairs of device configuration.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_sleeptimer(request)[source]
Request handler for the sleeptimer endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/sleeptimer
- Query Parameters:
cmd (string) – command (get or set)
time (int) – time in minutes (0 – 999)
action (string) – action (standby or shutdown)
enabled (string) – enabled (True or False)
confirmed (string) – confirmed (supported?)
- P_streamcurrentm3u(request)[source]
Request handler for the streamcurrentm3u endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/streamcurrent.m3u
- P_streamm3u(request)[source]
Request handler for the streamm3u endpoint.
Note
Parameters Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/stream.m3u
- Query Parameters:
ref (string) – service reference
name (string) – service name
- P_streamsubservices(request)[source]
Request handler for the streamsubservices endpoint.
See also
https://github.com/oe-alliance/OpenWebif/wiki/OpenWebif-API-documentation#streamsubservices
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/streamsubservices
- Query Parameters:
sRef (string) – service reference
- P_subservices(request)[source]
Request handler for the subservices endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_supports_powerup_without_waking_tv(request)[source]
Request handler for the supports_powerup_without_waking_tv endpoint. Check if ‘powerup without waking TV’ is available.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_timeradd(request)[source]
Request handler for the timeradd endpoint. Add timer
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_timeraddbyeventid(request)[source]
Request handler for the timeraddbyeventid endpoint. Add timer by event ID
See also
https://github.com/oe-alliance/OpenWebif/wiki/OpenWebif-API-documentation#timeraddbyeventid
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_timerchange(request)[source]
Request handler for the timerchange endpoint. Change timer
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/timerchange
- Query Parameters:
sRef (string) – service reference
begin (int) – begin timestamp
end (int) – end timestamp
name (string) – name
description (string) – description
channelOld (string) – old channel(?)
beginOld (int) – old begin timestamp(?)
endOld (int) – old end timestamp(?)
justplay (int) – Just Play indicator
dirname (string) – target path(?)
tags (string) – tags to add(?)
always_zap (int) – always zap first(?)
disabled (int) – disabled state
afterevent (int) – afterevent state
- P_timercleanup(request)[source]
Request handler for the timercleanup endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_timerdelete(request)[source]
Request handler for the timerdelete endpoint. Delete timer
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_timerlist(request)[source]
Request handler for the timerlist endpoint. Retrieve list of timers.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_timerlistwrite(request)[source]
Request handler for the timerlistwrite endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_timertogglestatus(request)[source]
Request handler for the timertogglestatus endpoint.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_tsm3u(request)[source]
Request handler for the tsm3u endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_tsstart(request)[source]
Request handler for the tsstart endpoint. Start timeshift (?).
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_tsstate(request, success=True)[source]
Request handler for the tsstate endpoint. Retrieve timeshift status(?).
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_tsstop(request)[source]
Request handler for the tsstop endpoint. Stop timeshift (?).
Note
Not available in Enigma2 WebInterface API.
TODO: improve after action / save , save+record , nothing config.timeshift.favoriteSaveAction ….
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_tunersignal(request)[source]
Request handler for the tunersignal endpoint. Get tuner signal status(?)
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- GET /web/signal
- P_tvbrowser(request)[source]
Request handler for the tvbrowser endpoint.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_vol(request)[source]
Request handler for the vol endpoint. Get/Set current volume setting.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers
- P_vpschannels(request)[source]
Request handler for the vpschannels endpoint.
Note
Not available in Enigma2 WebInterface API.
- Args:
request (twisted.web.server.Request): HTTP request object
- Returns:
HTTP response with headers