diff --git a/addon.xml b/addon.xml index 71f1395..a478ffb 100644 --- a/addon.xml +++ b/addon.xml @@ -1,7 +1,7 @@ diff --git a/resources/lib/movistar.py b/resources/lib/movistar.py index 8af403d..dd84d6b 100644 --- a/resources/lib/movistar.py +++ b/resources/lib/movistar.py @@ -1299,8 +1299,8 @@ class Movistar(object): channels = self.get_channels() res = [] for c in channels: - if not c['subscribed']: continue t = {} + t['subscribed'] = c['subscribed'] t['name'] = c['channel_name'] t['id'] = c['id'] t['logo'] = c['art']['icon'] @@ -1310,10 +1310,11 @@ class Movistar(object): res.append(t) return res - def export_channels_to_m3u8(self, filename): + def export_channels_to_m3u8(self, filename, only_subscribed=False): channels = self.export_channels() items = [] for t in channels: + if only_subscribed and not t['subscribed']: continue item = '#EXTINF:-1 tvg-name="{name}" tvg-id="{id}" tvg-logo="{logo}" tvg-chno="{preset}" group-title="Movistar+" catchup="vod",{name}\n{stream}\n\n'.format( name=t['name'], id=t['id'], logo=t['logo'], preset=t['preset'], stream=t['stream']) items.append(item) @@ -1326,14 +1327,13 @@ class Movistar(object): from urllib.parse import urlencode else: from urllib import urlencode - #now = time.time()*1000 res = {} epg = self.get_epg(date, duration) channels = self.get_channels() for channel in channels: id = channel['id'] - if not channel['subscribed'] or not id in epg: continue + if not id in epg: continue res[id] = [] for e in epg[id]: t = {} @@ -1342,8 +1342,6 @@ class Movistar(object): t['start'] = datetime.utcfromtimestamp(e['start']/1000).strftime('%Y-%m-%dT%H:%M:%SZ') t['stop'] = datetime.utcfromtimestamp(e['end']/1000).strftime('%Y-%m-%dT%H:%M:%SZ') - #aired = (e['end'] <= now) - #if aired: if True: program_id = str(e['show_id']) url = 'https://grmovistar.imagenio.telefonica.net/asfe/rest/tvMediaURLs?tvProgram.id='+ program_id +'&svc=startover' @@ -1351,8 +1349,7 @@ class Movistar(object): args = urlencode({'action': 'play', 'stype': 'u7d', 'id': program_id, 'url': url, 'session_request': session_request}) t['stream'] = 'plugin://plugin.video.movistarplus/?' + args - """ - if self.add_extra_info and id in ['HOLLYW', 'TCM', 'AMC', 'MV3', 'MV2', 'CPSER', 'FOXGE', 'TNT']: + if False and self.add_extra_info and id in ['HOLLYW', 'TCM', 'AMC', 'MV3', 'MV2', 'CPSER', 'FOXGE', 'TNT']: i = {'id': e['id'], 'show_id': e['show_id']} self.add_video_extra_info(i) #print(i) @@ -1363,12 +1360,11 @@ class Movistar(object): t['credits'].append({'type': 'director', 'name': text}) for text in i['info'].get('cast', []): t['credits'].append({'type': 'actor', 'name': text}) - """ res[id].append(t) return res - def export_epg_to_xml(self, filename, ndays=3, report_func=None): + def export_epg_to_xml(self, filename, ndays=3, report_func=None, only_subscribed=False): if sys.version_info[0] < 3: # Python 2 from cgi import escape as html_escape @@ -1383,6 +1379,7 @@ class Movistar(object): '\n') for t in channels: + if only_subscribed and not t['subscribed']: continue res.append('\n'.format(t['id']) + ' {}\n'.format(t['name']) + ' \n'.format(t['logo']) + @@ -1410,7 +1407,9 @@ class Movistar(object): for ch in channels: if not ch['id'] in epg: continue + if only_subscribed and not ch['subscribed']: continue for e in epg[ch['id']]: + #LOG('* e:{}'.format(e)) start = datetime.strptime(e['start'], "%Y-%m-%dT%H:%M:%SZ").strftime("%Y%m%d%H%M%S +0000") stop = datetime.strptime(e['stop'], "%Y-%m-%dT%H:%M:%SZ").strftime("%Y%m%d%H%M%S +0000") url = e.get('stream', None) diff --git a/resources/lib/plugin.py b/resources/lib/plugin.py index 5e7750b..1af1a62 100644 --- a/resources/lib/plugin.py +++ b/resources/lib/plugin.py @@ -681,12 +681,13 @@ def export_epg_now(): if sys.version_info[0] > 2: folder = bytes(folder, 'utf-8') if not folder or not os.path.isdir(folder): return + only_subscribed = addon.getSettingBool('only_subscribed') channels_filename = os.path.join(folder, b"movistar-channels.m3u8") epg_filename = os.path.join(folder, b"movistar-epg.xml") show_notification(addon.getLocalizedString(30310), xbmcgui.NOTIFICATION_INFO) - m.export_channels_to_m3u8(channels_filename) + m.export_channels_to_m3u8(channels_filename, only_subscribed) show_notification(addon.getLocalizedString(30311), xbmcgui.NOTIFICATION_INFO) - m.export_epg_to_xml(epg_filename, addon.getSettingInt('export_days'), report_progress) + m.export_epg_to_xml(epg_filename, addon.getSettingInt('export_days'), report_progress, only_subscribed) show_notification(addon.getLocalizedString(30313), xbmcgui.NOTIFICATION_INFO) def to_wishlist(params): diff --git a/resources/settings.xml b/resources/settings.xml index 7071a48..868c2f5 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -41,8 +41,8 @@ - - + + diff --git a/service.py b/service.py index 95ac9de..f134555 100644 --- a/service.py +++ b/service.py @@ -41,12 +41,23 @@ def export_epg(): reuse_devices = addon.getSettingBool('reuse_devices') m = Movistar(profile_dir, reuse_devices) if not m.logged: return + + if addon.getSettingBool('uhd'): + m.quality = 'UHD' + + profile_id = addon.getSetting('profile_id').upper() + LOG('profile_id: {}'.format(profile_id)) + if profile_id not in ['', 'AUTO']: + m.account['platform'] = profile_id + + only_subscribed = addon.getSettingBool('only_subscribed') + LOG('service: only_subscribed: {}'.format(only_subscribed)) if channels_needs_update: show_notification(addon.getLocalizedString(30310), xbmcgui.NOTIFICATION_INFO) - m.export_channels_to_m3u8(channels_filename) + m.export_channels_to_m3u8(channels_filename, only_subscribed) if epg_needs_update: show_notification(addon.getLocalizedString(30311), xbmcgui.NOTIFICATION_INFO) - m.export_epg_to_xml(epg_filename) + m.export_epg_to_xml(epg_filename, only_subscribed=only_subscribed) if __name__ == '__main__': LOG('Service started')