def syncMyAccounts(silent=False): try: all_acct = myaccounts.getAll() trakt_acct = all_acct.get('trakt') if control.setting('trakt.username') != trakt_acct.get('username'): control.setSetting('trakt.isauthed', 'true') control.setSetting('trakt.token', trakt_acct.get('token')) control.setSetting('trakt.username', trakt_acct.get('username')) control.setSetting('trakt.refresh', trakt_acct.get('refresh')) control.setSetting('trakt.expires', trakt_acct.get('expires')) ad_acct = all_acct.get('alldebrid') if control.setting('alldebrid.username') != ad_acct.get('username'): control.setSetting('alldebrid.token', ad_acct.get('token')) control.setSetting('alldebrid.username', ad_acct.get('username')) pm_acct = all_acct.get('premiumize') if control.setting('premiumize.username') != pm_acct.get('username'): control.setSetting('premiumize.token', pm_acct.get('token')) control.setSetting('premiumize.username', pm_acct.get('username')) rd_acct = all_acct.get('realdebrid') if control.setting('realdebrid.username') != rd_acct.get('username'): control.setSetting('realdebrid.token', rd_acct.get('token')) control.setSetting('realdebrid.username', rd_acct.get('username')) control.setSetting('realdebrid.client_id', rd_acct.get('client_id')) control.setSetting('realdebrid.refresh', rd_acct.get('refresh')) control.setSetting('realdebrid.secret', rd_acct.get('secret')) fanart_acct = all_acct.get('fanart_tv') if control.setting('fanart.tv.api.key') != fanart_acct.get('api_key'): control.setSetting('fanart.tv.api.key', fanart_acct.get('api_key')) tmdb_acct = all_acct.get('tmdb') if control.setting('tmdb.api.key') != tmdb_acct.get('api_key'): control.setSetting('tmdb.api.key', tmdb_acct.get('api_key')) if control.setting('tmdb.username') != tmdb_acct.get('username'): control.setSetting('tmdb.username', tmdb_acct.get('username')) if control.setting('tmdb.password') != tmdb_acct.get('password'): control.setSetting('tmdb.password', tmdb_acct.get('password')) if control.setting('tmdb.session_id') != tmdb_acct.get('session_id'): control.setSetting('tmdb.session_id', tmdb_acct.get('session_id')) tvdb_acct = all_acct.get('tvdb') if control.setting('tvdb.api.key') != tvdb_acct.get('api_key'): control.setSetting('tvdb.api.key', tvdb_acct.get('api_key')) imdb_acct = all_acct.get('imdb') if control.setting('imdb.user') != imdb_acct.get('user'): control.setSetting('imdb.user', imdb_acct.get('user')) fu_acct = all_acct.get('furk') if control.setting('furk.username') != fu_acct.get('username'): control.setSetting('furk.username', fu_acct.get('username')) control.setSetting('furk.password', fu_acct.get('password')) if fu_acct.get('api_key', None): if control.setting('furk.api') != fu_acct.get('api_key'): control.setSetting('furk.api', fu_acct.get('api_key')) if not silent: control.notification(message=32114) except: log_utils.error()
def clearCacheSearchPhrase(self, table, name): control.hide() if not control.yesnoDialog(control.lang(32056), '', ''): return try: from resources.lib.database import cache if cache.cache_clear_SearchPhrase(table, name): control.notification(message=32094) else: control.notification(message=33586) except: from resources.lib.modules import log_utils log_utils.error()
def clearBookmark(self, name, year): control.hide() if not control.yesnoDialog(control.lang(32056), '', ''): return try: from resources.lib.database import cache if cache.cache_clear_bookmark(name, year): control.notification(title=name, message=32102) else: control.notification(message=33586) except: from resources.lib.modules import log_utils log_utils.error()
def clearCacheProviders(self): control.hide() if not control.yesnoDialog(control.lang(32056), '', ''): return try: from resources.lib.database import providerscache if providerscache.cache_clear_providers(): control.notification(message=32090) else: control.notification(message=33586) except: from resources.lib.modules import log_utils log_utils.error()
def clearCacheMeta(self): control.hide() if not control.yesnoDialog(control.lang(32076), '', ''): return try: from resources.lib.database import metacache if metacache.cache_clear_meta(): control.notification(message=32091) else: control.notification(message=33586) except: from resources.lib.modules import log_utils log_utils.error()
def clearBookmark(self, name, year): control.hide() yes = control.yesnoDialog(control.lang(32056), '', '') if not yes: return try: from resources.lib.modules import cache cache.cache_clear_bookmark(name, year) control.notification(title=name, message='Bookmark Successfully Cleared!', icon='default', sound=(control.setting('notification.sound') == 'true')) except: log_utils.error() pass
def clearCacheSearchPhrase(self, table, name): control.hide() yes = control.yesnoDialog(control.lang(32056), '', '') if not yes: return try: from resources.lib.modules import cache cache.cache_clear_SearchPhrase(table, name) control.notification(title='default', message='Search Phrase Successfully Cleared!', icon='default', sound=(control.setting('notification.sound') == 'true')) except: log_utils.error() pass
def clearCacheMeta(self): control.hide() yes = control.yesnoDialog(control.lang(32076), '', '') if not yes: return try: from resources.lib.modules import cache cache.cache_clear_meta() control.notification(title='default', message='Metadata Cache Successfully Cleared!', icon='default', sound=(control.setting('notification.sound') == 'true')) except: log_utils.error() pass
def user_transfers_to_listItem(self): sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) transfer_files = self.user_cloud()['magnets'] if not transfer_files: control.notification(title='default', message='Request Failure-Empty Content', icon='default') return folder_str, deleteMenu, restartMenu = control.lang(40046).upper(), control.lang(40050), control.lang(40008) for count, item in enumerate(transfer_files, 1): # log_utils.log('item = %s' % str(item), __name__, log_utils.LOGDEBUG) try: status_code = item['statusCode'] if status_code in (0,1, 2, 3): active = True downloaded = item['downloaded'] size = item['size'] try: percent = str(round(float(downloaded)/size*100, 1)) except: percent = '0' else: active = False folder_name = item['filename'] # normalized_folder_name = normalize(folder_name) id = item['id'] status_str = '[COLOR %s]%s[/COLOR]' % (control.getColor(control.setting('highlight.color')), item['status'].capitalize()) if active: label = '%02d | [B]%s[/B] - %s | [B]%s[/B]' % (count, status_str, str(percent) + '%', folder_name) else: label = '%02d | [B]%s[/B] | [B]%s[/B] | [I]%s [/I]' % (count, status_str, folder_str, folder_name) if status_code == 4: url = '%s?action=ad_BrowseUserCloud&source=%s' % (sysaddon, json.dumps(item)) isFolder = True else: url = '' isFolder = False cm = [] cm.append((deleteMenu % 'Transfer', 'RunPlugin(%s?action=ad_DeleteTransfer&id=%s&name=%s)' % (sysaddon, id, folder_name))) if status_code in (6, 7, 9, 10): cm.append((restartMenu, 'RunPlugin(%s?action=ad_RestartTransfer&id=%s&name=%s)' % (sysaddon, id, folder_name))) item = control.item(label=label) item.addContextMenuItems(cm) item.setArt({'icon': ad_icon, 'poster': ad_icon, 'thumb': ad_icon, 'fanart': addonFanart, 'banner': ad_icon}) item.setInfo(type='video', infoLabels='') video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder) except: log_utils.error() pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)
def playlistRemove(name): labelPosition = position(label=name) if labelPosition >= 0: rpc = '{"jsonrpc": "2.0", "method": "Playlist.Remove", "params": {"playlistid": %s, "position": %s}, "id": 1 }' % (Id, labelPosition) control.jsonrpc(rpc) if notification: control.notification(title = 35522, message = str(name) + ' Removed from playlist', icon = 'INFO', sound = notificationSound) if labelPosition == -1: if notification: control.notification(title = 35522, message = 'Not found in playlist', icon = 'INFO', sound = notificationSound) # control.refresh()
def delete_download(self, media_id, name): try: if not control.yesnoDialog(getLS(40050) % '?\n' + name, '', ''): return ck_token = self._get('user', token_ck=True) # check token, and refresh if needed url = downloads_delete_url + "/%s&auth_token=%s" % (media_id, self.token) response = requests.delete(rest_base_url + url).text if response and not 'error' in response: if self.server_notifications: control.notification(message='Real-Debrid: %s was removed from your MyDownloads' % name, icon=rd_icon) log_utils.log('Real-Debrid: %s was removed from your MyDownloads' % name, __name__, log_utils.LOGDEBUG) control.refresh() return except: log_utils.error('Real-Debrid Error: DELETE DOWNLOAD %s : ' % name)
def _get(self, url): try: response = requests.get(url, headers=self.headers, timeout=15).json() if 'status' in response: if response.get('status') == 'success': return response if response.get( 'status') == 'error' and self.server_notifications: control.notification(message=response.get('message')) except: log_utils.error() return response
def playlistRemove(name): labelPosition = position(label=name) if labelPosition >= 0: rpc = '{"jsonrpc": "2.0", "method": "Playlist.Remove", "params": {"playlistid": %s, "position": %s}, "id": 1 }' % ( Id, labelPosition) control.jsonrpc(rpc) if notification: control.notification(title=35522, message=control.lang(32122) % str(name)) if labelPosition == -1: if notification: control.notification(title=35522, message=32123) # control.refresh()
def revoke_session_id(self): try: if control.setting('tmdb.session_id') == '': return url = self.auth_base_link + '/session?api_key=%s' % API_key post = {"session_id": "%s" % control.setting('tmdb.session_id')} result = requests.delete(url, data=post).json() if result.get('success') is True: control.setSetting('tmdb.session_id', '') control.notification(message='TMDb session_id successfully deleted') else: control.notification(message='TMDb session_id deletion FAILED', icon='ERROR') except: log_utils.error()
def reset(self, current_time, media_length, name, year='0'): if control.setting( 'bookmarks' ) != 'true' or media_length == 0 or current_time == 0: return timeInSeconds = str(current_time) ok = (int(current_time) > 180 and (current_time / media_length) <= .92) idFile = hashlib.md5() for i in name: idFile.update(str(i)) for i in year: idFile.update(str(i)) idFile = str(idFile.hexdigest()) control.makeFile(control.dataPath) dbcon = database.connect(control.bookmarksFile) dbcur = dbcon.cursor() # dbcur.execute("CREATE TABLE IF NOT EXISTS bookmark (""idFile TEXT, ""timeInSeconds TEXT, ""UNIQUE(idFile)"");") dbcur.execute("CREATE TABLE IF NOT EXISTS bookmark (" "idFile TEXT, " "timeInSeconds TEXT, " "Name TEXT, " "year TEXT, " "UNIQUE(idFile)" ");") dbcur.execute("DELETE FROM bookmark WHERE idFile = '%s'" % idFile) if ok: # dbcur.execute("INSERT INTO bookmark Values (?, ?)", (idFile, timeInSeconds)) dbcur.execute("INSERT INTO bookmark Values (?, ?, ?, ?)", (idFile, timeInSeconds, name, year)) minutes, seconds = divmod(float(timeInSeconds), 60) hours, minutes = divmod(minutes, 60) label = ('%02d:%02d:%02d' % (hours, minutes, seconds)).encode('utf-8') message = control.lang(32660).encode('utf-8') control.notification(title=name, message=message + '(' + label + ')', icon='INFO', sound=notificationSound) dbcur.connection.commit() dbcon.close()
def get_token(self): try: url = oauth_base_url + 'token' postData = { 'client_id': self.client_ID, 'client_secret': self.secret, 'code': self.device_code, 'grant_type': 'http://oauth.net/grant_type/device/1.0' } response = requests.post(url, data=postData) # log_utils.log('Authorizing Real Debrid Result: | %s |' % response, level=log_utils.LOGDEBUG) if '[204]' in str(response): return False, str(response) if 'Temporarily Down For Maintenance' in response.text: if self.server_notifications: control.notification( message='Real-Debrid Temporarily Down For Maintenance', icon=rd_icon) log_utils.log('Real-Debrid Temporarily Down For Maintenance', level=log_utils.LOGWARNING) return False, response.text else: response = response.json() if 'error' in str(response): log_utils.log('response=%s' % str(response), __name__) message = response.get('error') if self.server_notifications: control.notification(message=message, icon=rd_icon) log_utils.log('Real-Debrid Error: %s' % message, level=log_utils.LOGWARNING) return False, response self.token = response['access_token'] control.sleep(500) account_info = self.account_info() username = account_info['username'] control.setSetting('realdebrid.username', username) control.setSetting('realdebrid.client_id', self.client_ID) control.setSetting( 'realdebrid.secret', self.secret, ) control.setSetting('realdebrid.token', self.token) control.addon('script.module.myaccounts').setSetting( 'realdebrid.token', self.token) control.setSetting('realdebrid.refresh', response['refresh_token']) return True, None except: log_utils.error('Real Debrid Authorization Failed : ') return False, None
def clearViews(): try: skin = control.skin control.idle() yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '') if not yes: return control.makeFile(control.dataPath) dbcon = database.connect(control.viewsFile) dbcur = dbcon.cursor() for t in ['views']: try: dbcur.execute("DROP TABLE IF EXISTS %s" % t) dbcur.execute("VACUUM") dbcur.execute("CREATE TABLE IF NOT EXISTS views (" "skin TEXT, " "view_type TEXT, " "view_id TEXT, " "UNIQUE(skin, view_type)" ");") dbcur.connection.commit() dbcon.close() except: pass try: kodiDB = xbmc.translatePath('special://home/userdata/Database') kodiViewsDB = os.path.join(kodiDB, 'ViewModes6.db') dbcon = database.connect(kodiViewsDB) dbcur = dbcon.cursor() dbcur.execute( "DELETE FROM view WHERE path LIKE 'plugin://plugin.video.venom/%'" ) dbcur.connection.commit() dbcon.close() except: pass skinName = control.addon(skin).getAddonInfo('name') skinIcon = control.addon(skin).getAddonInfo('icon') control.notification(title=skinName, message='View Types Successfully Cleared!', icon=skinIcon, sound=notificationSound) except: import traceback traceback.print_exc() pass
def addDirectory(self, items, queue=False, isFolder=True): if items is None or len(items) == 0: control.hide() control.notification(title=32002, message=33049) sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonThumb = control.addonThumb() artPath = control.artPath() queueMenu = control.lang(32065) playRandom = control.lang(32535) addToLibrary = control.lang(32551) for i in items: try: name = i['name'] if i['image'].startswith('http'): thumb = i['image'] elif artPath: thumb = control.joinPath(artPath, i['image']) else: thumb = addonThumb try: item = control.item(label=name, offscreen=True) except: item = control.item(label=name) if isFolder: url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % quote_plus(i['url']) except: pass item.setProperty('IsPlayable', 'false') else: url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % i['url'] except: pass item.setProperty('IsPlayable', 'true') item.setInfo("mediatype", "video") item.setInfo("audio", '') item.setArt({ 'icon': thumb, 'thumb': thumb, 'fanart': control.addonFanart() }) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder) except: pass control.content(syshandle, 'addons') control.directory(syshandle, cacheToDisc=True)
def scrobbleReset(imdb, tvdb=None, season=None, episode=None, refresh=True): control.busy() try: type = 'movie' if not episode else 'episode' if type == 'movie': items = [{'type': 'movie', 'movie': {'ids': {'imdb': imdb}}}] getTrakt('/scrobble/start', { "movie": { "ids": { "imdb": imdb } }, "progress": 0 }) else: items = [{ 'type': 'episode', 'episode': { 'season': season, 'number': episode }, 'show': { 'ids': { 'imdb': imdb, 'tvdb': tvdb } } }] getTrakt( '/scrobble/start', { "show": { "ids": { "tvdb": tvdb } }, "episode": { "season": season, "number": episode }, "progress": 0 }) timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.000Z") items[0].update({'paused_at': timestamp}) traktsync.delete_bookmark(items) control.hide() if refresh: control.refresh() control.trigger_widget_refresh() if control.setting('trakt.scrobble.notify') == 'true': control.notification(message=32082) except: log_utils.error()
def my_files_to_listItem(self, folder_id=None, folder_name=None): try: sysaddon, syshandle = argv[0], int(argv[1]) extensions = supported_video_extensions() cloud_files = self.my_files(folder_id) if not cloud_files: if self.server_notifications: control.notification(message='Request Failure-Empty Content', icon=pm_icon) log_utils.log('Premiumize.me: Request Failure-Empty Content', __name__, log_utils.LOGDEBUG) return cloud_files = [i for i in cloud_files if ('link' in i and i['link'].lower().endswith(tuple(extensions))) or i['type'] == 'folder'] cloud_files = sorted(cloud_files, key=lambda k: k['name']) cloud_files = sorted(cloud_files, key=lambda k: k['type'], reverse=True) except: log_utils.error() return folder_str, file_str, downloadMenu, renameMenu, deleteMenu = control.lang(40046).upper(), control.lang(40047).upper(), control.lang(40048), control.lang(40049), control.lang(40050) for count, item in enumerate(cloud_files, 1): try: cm = [] type = item['type'] name = control.strip_non_ascii_and_unprintable(item['name']) if type == 'folder': isFolder = True size = 0 label = '%02d | [B]%s[/B] | [I]%s [/I]' % (count, folder_str, name) url = '%s?action=pm_MyFiles&id=%s&name=%s' % (sysaddon, item['id'], quote_plus(name)) else: isFolder = False url_link = item['link'] if url_link.startswith('/'): url_link = 'https' + url_link size = item['size'] display_size = float(int(size)) / 1073741824 label = '%02d | [B]%s[/B] | %.2f GB | [I]%s [/I]' % (count, file_str, display_size, name) url = '%s?action=play_URL&url=%s' % (sysaddon, url_link) cm.append((downloadMenu, 'RunPlugin(%s?action=download&name=%s&image=%s&url=%s&caller=premiumize)' % (sysaddon, quote_plus(name), quote_plus(pm_icon), url_link))) cm.append((renameMenu % type.capitalize(), 'RunPlugin(%s?action=pm_Rename&type=%s&id=%s&name=%s)' % (sysaddon, type, item['id'], quote_plus(name)))) cm.append((deleteMenu % type.capitalize(), 'RunPlugin(%s?action=pm_Delete&type=%s&id=%s&name=%s)' % (sysaddon, type, item['id'], quote_plus(name)))) item = control.item(label=label) item.addContextMenuItems(cm) item.setArt({'icon': pm_icon, 'poster': pm_icon, 'thumb': pm_icon, 'fanart': addonFanart, 'banner': pm_icon}) item.setInfo(type='video', infoLabels='') control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder) except: log_utils.error() control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)
def listAdd(successNotification = True): t = control.lang(32520).encode('utf-8') k = control.keyboard('', t) ; k.doModal() new = k.getText() if k.isConfirmed() else None if (new is None or new == ''): return result = getTrakt('/users/me/lists', post = {"name" : new, "privacy" : "private"}) try: slug = json.loads(result)['ids']['slug'] if successNotification: control.notification(title = 32070, message = 33661, icon = 'INFO', sound = False) return slug except: control.notification(title = 32070, message = 33584, icon = 'iNFO', sound = False) return None
def reset(self, current_time, media_length, name, year='0'): try: from resources.lib.modules import cache cache.clear_local_bookmarks() if control.setting( 'bookmarks' ) != 'true' or media_length == 0 or current_time == 0: return timeInSeconds = str(current_time) seekable = (int(current_time) > 180 and (current_time / media_length) <= .85) idFile = md5() try: [idFile.update(str(i)) for i in name] except: [idFile.update(str(i).encode('utf-8')) for i in name] try: [idFile.update(str(i)) for i in year] except: [idFile.update(str(i).encode('utf-8')) for i in year] idFile = str(idFile.hexdigest()) control.makeFile(control.dataPath) dbcon = database.connect(control.bookmarksFile) dbcur = dbcon.cursor() dbcur.execute( '''CREATE TABLE IF NOT EXISTS bookmark (idFile TEXT, timeInSeconds TEXT, Name TEXT, year TEXT, UNIQUE(idFile));''' ) years = [str(year), str(int(year) + 1), str(int(year) - 1)] dbcur.execute( '''DELETE FROM bookmark WHERE Name="%s" AND year IN (%s)''' % (name, ','.join(i for i in years)) ) #helps fix random cases where trakt and imdb, or tvdb, differ by a year for eps if seekable: dbcur.execute('''INSERT INTO bookmark Values (?, ?, ?, ?)''', (idFile, timeInSeconds, name, year)) minutes, seconds = divmod(float(timeInSeconds), 60) hours, minutes = divmod(minutes, 60) label = ('%02d:%02d:%02d' % (hours, minutes, seconds)) message = control.lang(32660) control.notification(title=name, message=message + '(' + label + ')') dbcur.connection.commit() try: dbcur.close dbcon.close() except: pass except: log_utils.error()
def silent(self, url): control.hide() contains = lib_tools().ckKodiSources() if service_notification and not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo'): control.notification(message=32645) from resources.lib.menus import tvshows items = tvshows.TVshows().get(url, idx=False) if items is None: items = [] total_added = 0 for i in items: if control.monitor.abortRequested(): return sys.exit() try: files_added = self.add(i['title'], i['year'], i['imdb'], i['tmdb'], i['tvdb'], range=True) if general_notification and files_added > 0: control.notification(title=i['title'], message=32554) if files_added > 0: total_added += 1 except: log_utils.error() if self.library_update == 'true' and not control.condVisibility('Library.IsScanningVideo') and total_added > 0: if contains: control.sleep(10000) control.execute('UpdateLibrary(video)') elif service_notification: control.notification(message=32103) if service_notification: control.notification(message='Trakt TV Show Sync Complete')
def silent(self, url): control.idle() contains = lib_tools.ckKodiSources() if service_notification and not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo'): control.notification(title = 'default', message = 32645, icon = 'default', time = 1000, sound = notificationSound) from resources.lib.menus import tvshows items = tvshows.TVshows().get(url, idx=False) if items is None: items = [] total_added = 0 for i in items: try: if xbmc.abortRequested is True: return sys.exit() files_added = self.add(i['title'], i['year'], i['imdb'], i['tvdb'], range=True) if general_notification and files_added > 0: control.notification(title = i['title'], message = 32554, icon = 'default', time = 1000, sound = notificationSound) total_added += 1 except: log_utils.error() pass if self.library_update == 'true' and not control.condVisibility('Library.IsScanningVideo') and total_added > 0: if contains: control.sleep(10000) control.execute('UpdateLibrary(video)') elif service_notification: control.notification(title = 'default', message = 'strm files written but library cannot be updated', icon = 'default', time = 2000, sound = notificationSound) if service_notification: control.notification(title = 'default', message = 'Trakt TV Show Sync Complete', icon = 'default', time = 1000, sound = notificationSound)
def addEpisodes(meta, content): try: item = dict() meta = json.loads(meta) content = "episode" try: id = meta['imdb'] if id == '' or id is None: id = meta['tvdb'] except: id = meta['episodeIDS']['trakt'] if 'title' in meta: title = item['title'] = meta['title'] if 'tvshowtitle' in meta: title = item['tvshowtitle'] = meta['tvshowtitle'] if 'year' in meta: item['year'] = meta['year'] if 'tvshowyear' in meta: item['tvshowyear'] = meta['tvshowyear'] if 'poster' in meta: item['poster'] = meta['poster'] if 'fanart' in meta: item['fanart'] = meta['fanart'] if 'clearart' in meta: item['clearart'] = meta['clearart'] if 'clearlogo' in meta: item['clearlogo'] = meta['clearlogo'] if 'imdb' in meta: item['imdb'] = meta['imdb'] if 'tmdb' in meta: item['tmdb'] = meta['tmdb'] if 'tvdb' in meta: item['tvdb'] = meta['tvdb'] if 'episodeIDS' in meta: item['episodeIDS'] = meta['episodeIDS'] if 'episode' in meta: item['episode'] = meta['episode'] if 'season' in meta: item['season'] = meta['season'] if 'premiered' in meta: item['premiered'] = meta['premiered'] if 'original_year' in meta: item['original_year'] = meta['original_year'] control.makeFile(dataPath) dbcon = database.connect(favouritesFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS %s (" "id TEXT, " "items TEXT, " "UNIQUE(id)" ");" % content) dbcur.execute("DELETE FROM %s WHERE id = '%s'" % (content, id)) dbcur.execute("INSERT INTO %s Values (?, ?)" % content, (id, repr(item))) dbcon.commit() control.refresh() control.notification(title=title, message='Added to Favorites', icon='INFO', sound=True) except: return
def listAdd(successNotification=True): t = control.lang(32520) k = control.keyboard('', t) ; k.doModal() new = k.getText() if k.isConfirmed() else None if not new: return result = getTrakt('/users/me/lists', post = {"name" : new, "privacy" : "private"}) try: slug = jsloads(result)['ids']['slug'] if successNotification: control.notification(title=32070, message=33661) return slug except: control.notification(title=32070, message=33584) return None
def hideItem(name, imdb=None, tvdb=None, season=None, episode=None, refresh=True): sections = ['progress_watched', 'calendar'] sections_display = [control.lang(40072), control.lang(40073)] selection = control.selectDialog([i for i in sections_display], heading=control.addonInfo('name') + ' - ' + control.lang(40074)) if selection == -1: return section = sections[selection] if episode: post = {"shows": [{"ids": {"tvdb": tvdb}}]} else: post = {"movies": [{"ids": {"imdb": imdb}}]} getTrakt('users/hidden/%s' % section, post=post)[0] if refresh: control.refresh() control.trigger_widget_refresh() if control.setting('trakt.general.notifications') == 'true': control.notification(title=32315, message=control.lang(33053) % (name, sections_display[selection]))
def docu_play(self, url): try: docu_page = client.request(url) docu_item = client.parseDOM(docu_page, 'meta', attrs={'itemprop': 'embedUrl'}, ret='content')[0] if 'http:' not in docu_item and 'https:' not in docu_item: docu_item = 'https:' + docu_item url = docu_item # docu_title = client.parseDOM(docu_page, 'meta', attrs={'property':'og:title'}, ret='content')[0].encode('utf-8', 'ignore').decode('utf-8').replace("&","&").replace(''',"'").replace('"','"').replace(''',"'").replace('–',' - ').replace('’',"'").replace('‘',"'").replace('&','&').replace('â','') docu_title = client.parseDOM( docu_page, 'meta', attrs={'property': 'og:title'}, ret='content')[0].replace("&", "&").replace( ''', "'").replace('"', '"').replace(''', "'").replace( '–', ' - ').replace('’', "'").replace( '‘', "'").replace('&', '&').replace('â', '') if 'youtube' in url: if 'videoseries' not in url: video_id = client.parseDOM( docu_page, 'div', attrs={'class': 'youtube-player'}, ret='data-id')[0] url = 'plugin://plugin.video.youtube/play/?video_id=%s' % video_id else: pass elif 'dailymotion' in url: video_id = client.parseDOM(docu_page, 'div', attrs={'class': 'youtube-player'}, ret='data-id')[0] url = self.getDailyMotionStream(video_id) else: log_utils.log('Play Documentary: Unknown Host: ' + str(url), level=log_utils.LOGDEBUG) control.notification( message='Unknown Host - Report To Developer: ' + str(url)) control.execute('PlayMedia(%s)' % url) # item = xbmcgui.ListItem(str(docu_title), iconImage='DefaultVideo.png', thumbnailImage='DefaultVideo.png') # iconImage and thumbnailImage removed in Kodi Matrix # item.setInfo(type='video', infoLabels={'Title': str(docu_title), 'Plot': str(docu_title)}) # item.setProperty('IsPlayable','true') # item.setPath(url) # control.resolve(int(sys.argv[1]), True, item) except: log_utils.error('docu_play() Exception: ')
def clearBookmarks(self): control.idle() yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '') if not yes: return try: from resources.lib.modules import cache cache.cache_clear_bookmarks() control.notification(title = 'default', message = 'Bookmarks Successfully Cleared!', icon = 'default', sound = notificationSound) except: log_utils.error() pass
def clearCacheSearchPhrase(self, table, name): control.idle() yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '') if not yes: return try: from resources.lib.modules import cache cache.cache_clear_SearchPhrase(table, name) control.notification(title = 'default', message = 'Search Phrase Successfully Cleared!', icon = 'default', sound = notificationSound) except: log_utils.error() pass