def contextMenu(self, context_menu, context_action, context_id, context_ui=''): deleted = False added = False with kodiutils.busy_dialog(): if context_menu and context_action and context_id: if context_menu and context_action and context_id: user = kodiutils.getSetting('email') password = kodiutils.getSetting('password') if user and password and self.med.login(user, password): if context_action == 'add': added = self.med.AggiungiLista( context_menu, context_id) elif context_action == 'del': deleted = self.med.EliminaLista( context_menu, context_id) if added: kodiutils.notify('Aggiunto a {}'.format( self.contextMenuMap[context_menu]), icon=kodiutils.getMedia('notify.png')) elif deleted: kodiutils.notify('Rimosso da {}'.format( self.contextMenuMap[context_menu]), icon=kodiutils.getMedia('notify.png')) update_dir = context_ui == 'refresh' and (added or deleted) kodiutils.endScript(closedir=False, update_dir=update_dir)
def continuewatch(self): user = kodiutils.getSetting('email') password = kodiutils.getSetting('password') if user and password and self.med.login(user, password): els, _ = self.med.OttieniContinuaGardare() self.__analizza_elenco(els) kodiutils.endScript()
def watchlist(self): user = kodiutils.getSetting('email') password = kodiutils.getSetting('password') if user and password and self.med.login(user, password): els, _ = self.med.OttieniWatchlist() self.__analizza_elenco(els, isDeletable=True, delete_list='watchlist', context_ui='refresh') kodiutils.endScript()
def scrobble(self, **data): guid = data['guid'] if 'guid' in data else '' position = data['position'] if 'position' in data else 0 duration = data['duration'] if 'duration' in data else 0 action = data['action'] if 'action' in data else '' kodiutils.log( "[mediasetservice] scrobble: action={}, guid={}, position={}, duration={}" .format(action, guid, position, duration)) if position and guid and duration: user = kodiutils.getSetting('email') password = kodiutils.getSetting('password') if user and password and self.med.login(user, password): self.med.setProgress(guid, position, duration)
def __init__(self): self.med = Mediaset() self.med.log = kodiutils.log self.iperpage = int(kodiutils.getSetting('itemsperpage')) self.ua = ( 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' '(KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36')
def riproduci_video(self, pid, live=False): from inputstreamhelper import Helper # pylint: disable=import-error kodiutils.log("Trying to get the video from pid" + pid) data = self.med.OttieniDatiVideo(pid, live) 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} if data['security']: 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.setResolvedUrl(data['url'], headers=headers, ins=is_helper.inputstream_addon, insdata=props)
def __init__(self): self.med = Mediaset() self.med.log = kodiutils.log self.iperpage = kodiutils.getSetting('itemsperpage') self.detect_media_type = kodiutils.getSettingAsBool('detectmediatype') self.lookup_fullplot = kodiutils.getSettingAsBool('lookupfullplot') self.isAnonimous = self.checkCredentials() self.ua = ( 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ' '(KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36')
def addVideosItems(id='', type=1, page=1): kodiutils.setContent('videos') res = [] loadAll = kodiutils.getSettingAsBool('loadAll') elPerPage = kodiutils.getSetting('elPerPage') if type==1: res = getProgramVideos(id, page, elPerPage, loadAll) elif type==2: res = getDateVideos(id) elif type==3: res = getCategoryVideos(id, elPerPage) elif type==4: res = getPicksVideos(elPerPage) if res: for ep in res: ep['mediatype']='video' kodiutils.addListItem(ep['title'], params={"id": ep['id'], "mode": "video" }, thumb=ep['image'], videoInfo=ep, isFolder=False) if type == 1 and (not loadAll) and len(getProgramVideos(id, int(page)+1, elPerPage))>0: kodiutils.addListItem(kodiutils.LANGUAGE(32011), params={"id": id, "mode": "program", "page": int(page) + 1}) kodiutils.endScript()
def __imposta_range(self): limit = '0-' + kodiutils.getSetting('itemsperpage') return limit
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)
def checkCredentials(self): user = kodiutils.getSetting('email') password = kodiutils.getSetting('password') return user == '' or password == ''