def vod_seasons(self, id): if self._debug_mode: log.debug('Executing: api.vod_seasons') log.debug('Vars: id={id}'.format(id=id)) seasons = [] program_url = '{api_url}/CONTENT/DETAIL/GROUP_OF_BUNDLES/{id}'.format( api_url=self._api_url, id=id) file = "cache" + os.sep + "vod_seasons_" + unicode(id) + ".json" if self._enable_cache and not is_file_older_than_x_minutes( file=ADDON_PROFILE + file, minutes=10): data = load_file(file=file, isJSON=True) else: data = self.download(url=program_url, type='get', code=[200], data=None, json_data=False, data_return=True, return_json=True, retry=True, check_data=True) if data and check_key(data['resultObj'], 'containers') and self._enable_cache: write_file(file=file, data=data, isJSON=True) if not data or not check_key(data['resultObj'], 'containers'): if self._debug_mode: log.debug('Failure to retrieve expected data') log.debug('Execution Done: api.vod_seasons') return None for row in data['resultObj']['containers']: for currow in row['containers']: if check_key(currow, 'metadata') and check_key( currow['metadata'], 'season' ) and currow['metadata']['contentSubtype'] == 'SEASON': seasons.append({ 'id': currow['metadata']['contentId'], 'seriesNumber': currow['metadata']['season'], 'desc': currow['metadata']['shortDescription'], 'image': currow['metadata']['pictureUrl'] }) if self._debug_mode: log.debug('Execution Done: api.vod_seasons') return seasons
def vod_seasons(self, id): profile_settings = load_profile(profile_id=1) seasons = [] program_url = '{api_url}/CONTENT/DETAIL/GROUP_OF_BUNDLES/{id}'.format( api_url=profile_settings['api_url'], id=id) file = "cache" + os.sep + "vod_seasons_" + unicode(id) + ".json" if settings.getBool( key='enable_cache') and not is_file_older_than_x_minutes( file=ADDON_PROFILE + file, minutes=10): data = load_file(file=file, isJSON=True) else: if not self.get_session(): return None download = self.download(url=program_url, type='get', headers=None, data=None, json_data=True, return_json=True) data = download['data'] resp = download['resp'] if resp and resp.status_code == 200 and data and check_key( data, 'resultCode') and data['resultCode'] == 'OK' and check_key( data, 'resultObj') and check_key( data['resultObj'], 'containers') and settings.getBool( key='enable_cache'): write_file(file=file, data=data, isJSON=True) if not data or not check_key(data['resultObj'], 'containers'): return None for row in data['resultObj']['containers']: for currow in row['containers']: if check_key(currow, 'metadata') and check_key( currow['metadata'], 'season' ) and currow['metadata']['contentSubtype'] == 'SEASON': seasons.append({ 'id': currow['metadata']['contentId'], 'seriesNumber': currow['metadata']['season'], 'desc': currow['metadata']['shortDescription'], 'image': currow['metadata']['pictureUrl'] }) return seasons
def vod_season(self, id): if self._debug_mode: log.debug('Executing: api.vod_season') log.debug('Vars: id={id}'.format(id=id)) season = [] episodes = [] program_url = '{api_url}/CONTENT/DETAIL/BUNDLE/{id}'.format( api_url=self._api_url, id=id) file = "cache" + os.sep + "vod_season_" + unicode(id) + ".json" if self._enable_cache and not is_file_older_than_x_minutes( file=ADDON_PROFILE + file, minutes=10): data = load_file(file=file, isJSON=True) else: data = self.download(url=program_url, type='get', code=[200], data=None, json_data=False, data_return=True, return_json=True, retry=True, check_data=True) if data and check_key(data['resultObj'], 'containers') and self._enable_cache: write_file(file=file, data=data, isJSON=True) if not data or not check_key(data['resultObj'], 'containers'): if self._debug_mode: log.debug('Failure to retrieve expected data') log.debug('Execution Done: api.vod_season') return None for row in data['resultObj']['containers']: for currow in row['containers']: if check_key(currow, 'metadata') and check_key( currow['metadata'], 'season') and currow['metadata'][ 'contentSubtype'] == 'EPISODE' and not currow[ 'metadata']['episodeNumber'] in episodes: asset_id = '' for asset in currow['assets']: if check_key( asset, 'videoType' ) and asset['videoType'] == 'SD_DASH_PR' and check_key( asset, 'assetType' ) and asset['assetType'] == 'MASTER': asset_id = asset['assetId'] break episodes.append(currow['metadata']['episodeNumber']) season.append({ 'id': currow['metadata']['contentId'], 'assetid': asset_id, 'duration': currow['metadata']['duration'], 'title': currow['metadata']['episodeTitle'], 'episodeNumber': '{season}.{episode}'.format( season=currow['metadata']['season'], episode=currow['metadata']['episodeNumber']), 'desc': currow['metadata']['shortDescription'], 'image': currow['metadata']['pictureUrl'] }) if self._debug_mode: log.debug('Execution Done: api.vod_season') return season
def vod_season(self, id): profile_settings = load_profile(profile_id=1) season = [] episodes = [] program_url = '{api_url}/CONTENT/DETAIL/BUNDLE/{id}'.format( api_url=profile_settings['api_url'], id=id) file = "cache" + os.sep + "vod_season_" + unicode(id) + ".json" if settings.getBool( key='enable_cache') and not is_file_older_than_x_minutes( file=ADDON_PROFILE + file, minutes=10): data = load_file(file=file, isJSON=True) else: if not self.get_session(): return None download = self.download(url=program_url, type='get', headers=None, data=None, json_data=True, return_json=True) data = download['data'] resp = download['resp'] if resp and resp.status_code == 200 and data and check_key( data, 'resultCode') and data['resultCode'] == 'OK' and check_key( data, 'resultObj') and check_key( data['resultObj'], 'containers') and settings.getBool( key='enable_cache'): write_file(file=file, data=data, isJSON=True) if not data or not check_key(data['resultObj'], 'containers'): return None for row in data['resultObj']['containers']: for currow in row['containers']: if check_key(currow, 'metadata') and check_key( currow['metadata'], 'season') and currow['metadata'][ 'contentSubtype'] == 'EPISODE' and not currow[ 'metadata']['episodeNumber'] in episodes: asset_id = '' for asset in currow['assets']: if check_key( asset, 'videoType' ) and asset['videoType'] == 'SD_DASH_PR' and check_key( asset, 'assetType' ) and asset['assetType'] == 'MASTER': asset_id = asset['assetId'] break episodes.append(currow['metadata']['episodeNumber']) season.append({ 'id': currow['metadata']['contentId'], 'assetid': asset_id, 'duration': currow['metadata']['duration'], 'title': currow['metadata']['episodeTitle'], 'episodeNumber': '{season}.{episode}'.format( season=currow['metadata']['season'], episode=currow['metadata']['episodeNumber']), 'desc': currow['metadata']['shortDescription'], 'image': currow['metadata']['pictureUrl'] }) return season
def vod_season(self, id): season = [] file = "cache" + os.sep + "vod_season_" + unicode(id) + ".json" if settings.getBool( key='enable_cache') and not is_file_older_than_x_minutes( file=ADDON_PROFILE + file, minutes=10): data = load_file(file=file, isJSON=True) else: profile_settings = load_profile(profile_id=1) headers = CONST_BASE_HEADERS headers.update({'Content-Type': 'application/json'}) headers.update({'X_CSRFToken': profile_settings['csrf_token']}) session_post_data = { 'VODID': unicode(id), 'offset': '0', 'count': '35', } seasons_url = '{base_url}/VSP/V3/QueryEpisodeList?from=throughMSAAccess'.format( base_url=CONST_BASE_URL) download = self.download(url=seasons_url, type='post', headers=headers, data=session_post_data, json_data=True, return_json=True) data = download['data'] resp = download['resp'] if resp and resp.status_code == 200 and data and check_key( data, 'result') and check_key( data['result'], 'retCode') and data['result'][ 'retCode'] == '000000000' and check_key( data, 'episodes') and settings.getBool( key='enable_cache'): write_file(file=file, data=data, isJSON=True) if not data or not check_key(data, 'episodes'): return None for row in data['episodes']: if check_key( row, 'VOD') and check_key(row['VOD'], 'ID') and check_key( row['VOD'], 'name') and check_key(row, 'sitcomNO'): image = '' duration = 0 if not check_key(row['VOD'], 'mediaFiles') or not check_key( row['VOD']['mediaFiles'][0], 'ID'): continue if check_key(row['VOD']['mediaFiles'][0], 'elapseTime'): duration = row['VOD']['mediaFiles'][0]['elapseTime'] if check_key(row['VOD'], 'picture') and check_key( row['VOD']['picture'], 'posters'): image = row['VOD']['picture']['posters'][0] season.append({ 'id': row['VOD']['ID'], 'media_id': row['VOD']['mediaFiles'][0]['ID'], 'duration': duration, 'title': row['VOD']['name'], 'episodeNumber': row['sitcomNO'], 'desc': '', 'image': image }) return season