X-Git-Url: https://git.rvb.name/vpproxy.git/blobdiff_plain/1e2c0e679beb33f10c2e551768c17ccd77576b54..1aebc74d991c35b7eb82395434d543d44f536089:/plugins/modules/PlaylistGenerator.py diff --git a/plugins/modules/PlaylistGenerator.py b/plugins/modules/PlaylistGenerator.py index e5402b2..4e7654c 100644 --- a/plugins/modules/PlaylistGenerator.py +++ b/plugins/modules/PlaylistGenerator.py @@ -12,7 +12,7 @@ class PlaylistGenerator(object): '#EXTM3U url-tvg="http://www.teleguide.info/download/new3/jtv.zip"\n' m3uemptyheader = '#EXTM3U\n' m3uchanneltemplate = \ - '#EXTINF:-1 group-title="%s" tvg-name="%s" tvg-logo="%s",%s\n%s\n' + '#EXTINF:-1 group-title="%s" tvg-name="%s" tvg-logo="%s" country="%s",%s\n%s\n' def __init__(self): self.itemlist = list() @@ -24,6 +24,7 @@ class PlaylistGenerator(object): name - item name url - item URL tvg - item JTV name (optional) + country - country of origin (optional) group - item playlist group (optional) logo - item logo file name (optional) ''' @@ -34,11 +35,16 @@ class PlaylistGenerator(object): ''' Generates EXTINF line with url ''' + print(item) return PlaylistGenerator.m3uchanneltemplate % ( - item.get('group', ''), item.get('tvg', ''), item.get('logo', ''), - item.get('name'), item.get('url')) + item.get('group', ''), + item.get('tvg', ''), + item.get('logo', ''), + item.get('country', ''), + item.get('name'), + item.get('url')) - def exportm3u(self, hostport, add_ts=False, empty_header=False, archive=False): + def exportm3u(self, hostport, prefix="get", add_ts=False, empty_header=False, archive=False): ''' Exports m3u playlist ''' @@ -54,7 +60,21 @@ class PlaylistGenerator(object): item['tvg'] = item.get('tvg', '') if item.get('tvg') else \ item.get('name').replace(' ', '_') # For .acelive and .torrent - item['url'] = 'http://' + hostport + '/get/'+item['url'] + item['url'] = 'http://' + hostport + '/' + prefix + '/' + item['url'] + itemlist += PlaylistGenerator._generatem3uline(item) + + return itemlist + + def dumpm3u(self): + ''' + Dump m3u playlist + ''' + itemlist = PlaylistGenerator.m3uemptyheader + + for item in self.itemlist: + item['tvg'] = item.get('tvg', '') if item.get('tvg') else \ + item.get('name').replace(' ', '_') + # For .acelive and .torrent itemlist += PlaylistGenerator._generatem3uline(item) return itemlist