def __init__(self): self.med = Mediaset() self.med.setUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36' self.med.log = kodiutils.log self.scrobblingInterval = kodiutils.getSettingAsNum( "scrobblingInterval") kodiutils.log('[mediasetservice] monitorService init')
# -*- coding: utf-8 -*- from resources.lib.monitor import MediasetService from phate89lib import kodiutils # pyright: reportMissingImports=false scrobbling = kodiutils.getSettingAsNum("scrobbling") if scrobbling: kodiutils.log( 'Addon {} starting {} scrobbling service (version {})'.format( kodiutils.ID, kodiutils.NAME, kodiutils.VERSION)) try: MediasetService().run() except Exception as exc: kodiutils.log('[mediasetservice] Exception: {}'.format(str(exc))) kodiutils.log( 'Addon {} shutting down {} scrobbling service (version {})'.format( kodiutils.ID, kodiutils.NAME, kodiutils.VERSION))
def main(self): # parameter values params = staticutils.getParams() kodiutils.log("[main] params: {}".format(str(params))) if 'mode' in params: page = None if 'page' in params: try: page = int(params['page']) except ValueError: pass self.iperpage = min(kodiutils.getSettingAsNum('itemsperpage'), 10) if params['mode'] == "cerca": if 'type' in params: if 'search' in params: self.elenco_cerca_sezione(params['type'], params['search'], page) else: self.apri_ricerca(params['type']) else: self.elenco_cerca_root() if params['mode'] == "sezione": self.elenco_sezione( **self.sliceParams(params, ('id', 'page', 'sort', 'order'))) if params['mode'] == "ondemand": if 'id' in params: self.elenco_ondemand( **self.sliceParams(params, ('id', 'template', 'sort', 'order'))) else: self.elenco_ondemand_root() if params['mode'] == "cult": if 'feedurl' in params: self.elenco_cult( **self.sliceParams(params, ('feedurl', 'page_action'))) else: self.elenco_cult_root() if params['mode'] == "magazine": if 'newsFeedUrl' in params: self.elenco_magazine( **self.sliceParams(params, ('newsFeedUrl', 'page_action'))) elif 'ddg_url' in params: self.elenco_news(params['ddg_url']) if params['mode'] == "programma": if 'series_id' in params: self.elenco_stagioni_list( **self.sliceParams(params, ('series_id', 'title', 'sort', 'order'))) elif 'sub_brand_id' in params: self.elenco_video_list( **self.sliceParams(params, ('sub_brand_id', 'mode', 'sort', 'page', 'size'))) elif 'brand_id' in params: self.elenco_sezioni_list(params['brand_id']) if params['mode'] == "video": if 'pid' in params: self.riproduci_video( **self.sliceParams(params, ('guid', 'pid', 'offset'))) else: self.riproduci_guid( **self.sliceParams(params, ('guid', 'offset'))) if params['mode'] == "live": if 'id' in params: self.riproduci_video(pid=params['id'], live=True) else: self.canali_live_play(params['guid']) if params['mode'] == "tv": self.tv_root() if params['mode'] == "personal": self.personal_root() elif params['mode'] == "continuewatch": self.continuewatch() elif params['mode'] == "favorites": self.favorites() elif params['mode'] == "watchlist": self.watchlist() elif params['mode'] == "contextmenu": self.contextMenu( **self.sliceParams(params, ('context_menu', 'context_action', 'context_id', 'context_ui'))) elif params['mode'] == "canali_live": self.canali_live_root() elif params['mode'] == "guida_tv": if 'id' in params: if 'week' in params: self.guida_tv_canale_settimana(params['id'], int(params['week'])) elif 'day' in params: self.guida_tv_canale_giorno(params['id'], int(params['day'])) self.guida_tv_root() else: self.root()
def __init__(self, *args, **kwargs): self.action = kwargs['action'] self._scrobbling = kodiutils.getSettingAsNum("scrobbling") self._clear() kodiutils.log("[mediasetservice] player initialiazed")
def riproduci_video(self, guid=None, pid=None, live=False, offset=None): from inputstreamhelper import Helper # pylint: disable=import-error # kodiutils.log("Trying to get the video from pid %s" % pid) kodiutils.log( 'riproduci_video: guid={}, pid={}, live={}, offset={}'.format( guid, pid, live, offset)) data = self.med.OttieniDatiVideo(pid, live) kodiutils.log('riproduci_video: data={}'.format(str(data))) if data['type'] == 'video/mp4': kodiutils.setResolvedUrl(data['url']) return is_helper = Helper('mpd', 'com.widevine.alpha' if data['security'] else None) if not is_helper.check_inputstream(): kodiutils.showOkDialog(kodiutils.LANGUAGE(32132), kodiutils.LANGUAGE(32133)) kodiutils.setResolvedUrl(solved=False) return headers = '&User-Agent={useragent}'.format(useragent=self.ua) props = {'manifest_type': 'mpd', 'stream_headers': headers} properties = {'ResumeTime': '0.0'} isAutenticated = False scrobbling = kodiutils.getSettingAsNum('scrobbling') if scrobbling and not self.isAnonimous: properties['guid'] = guid if scrobbling == self.ADDON_SCROBBLING_CUSTOM: if offset: properties['offset'] = str(offset) else: user = kodiutils.getSetting('email') password = kodiutils.getSetting('password') isAutenticated = self.med.login(user, password) if isAutenticated: offset = self.med.getProgress(guid) if offset: properties['offset'] = str(offset) if data['security']: if not isAutenticated: user = kodiutils.getSetting('email') password = kodiutils.getSetting('password') if user == '' or password == '': kodiutils.showOkDialog(kodiutils.LANGUAGE(32132), kodiutils.LANGUAGE(32134)) kodiutils.setResolvedUrl(solved=False) return if not self.med.login(user, password): kodiutils.showOkDialog(kodiutils.LANGUAGE(32132), kodiutils.LANGUAGE(32135)) kodiutils.setResolvedUrl(solved=False) return headers += '&Accept=*/*&Content-Type=' props['license_type'] = 'com.widevine.alpha' props['stream_headers'] = headers url = self.med.OttieniWidevineAuthUrl(data['pid']) props['license_key'] = '{url}|{headers}|R{{SSM}}|'.format( url=url, headers=headers) headers = { 'user-agent': self.ua, 't-apigw': self.med.apigw, 't-cts': self.med.cts } kodiutils.log("riproduci_video properties: %s" % properties) kodiutils.setResolvedUrl(data['url'], headers=headers, ins=is_helper.inputstream_addon, insdata=props, properties=properties)