def clearBookmark(self, name, year): control.hide() if not control.yesnoDialog(control.lang(32056), '', ''): return try: from resources.lib.modules import cache if cache.cache_clear_bookmark(name, year): control.notification(title=name, message=32102) else: control.notification(message=33586) except: log_utils.error()
def persons(self, url): if url is None: self.list = cache.get(self.imdb_person_list, 24, self.personlist_link) else: self.list = cache.get(self.imdb_person_list, 1, url) if len(self.list) == 0: control.hide() control.notification(title=32010, message=33049) for i in range(0, len(self.list)): self.list[i].update({'icon': 'DefaultActor.png', 'action': 'movies'}) self.addDirectory(self.list) return self.list
def _return_failed(message=control.lang(33586)): try: control.progressDialog.close() except: pass self.delete_torrent(torrent_id) control.hide() control.sleep(500) control.okDialog(title=control.lang(40018), message=message) return False
def _return_failed(message=getLS(33586)): try: control.progressDialog.close() except: pass self.delete_transfer(transfer_id) control.hide() control.sleep(500) control.okDialog(title=getLS(40018), message=message) return False
def clearCacheSearch(self): control.hide() if not control.yesnoDialog(control.lang(32056), '', ''): return try: from resources.lib.database import cache if cache.cache_clear_search(): control.notification(message=32093) else: control.notification(message=33586) except: from resources.lib.modules import log_utils log_utils.error()
def _error(url, post, timestamp, message): _cache(url=url, post=post, timestamp=timestamp) if control.setting('trakt.server.notifications') == 'true': control.notification( title=32315, message=message, icon='default', sound=(control.setting('notification.sound') == 'true')) control.hide() return None
def clearCacheSearchPhrase(self, table, name): control.hide() if not control.yesnoDialog(control.lang(32056), '', ''): return try: from resources.lib.modules import cache if cache.cache_clear_SearchPhrase(table, name): control.notification(message=32094) else: control.notification(message=33586) except: log_utils.error()
def clearCacheMeta(self): control.hide() if not control.yesnoDialog(control.lang(32076), '', ''): return try: from resources.lib.modules import cache if cache.cache_clear_meta(): control.notification(message=32091) else: control.notification(message=33586) except: 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: log_utils.error()
def clearBookmarks(self): control.hide() if not control.yesnoDialog(control.lang(32056), '', ''): return try: from resources.lib.database import cache if cache.cache_clear_bookmarks(): control.notification(message=32100) else: control.notification(message=33586) except: 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 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 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 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 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 clearCache(self): control.hide() yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '') if not yes: return try: from resources.lib.modules import cache cache.cache_clear() control.notification(title='default', message='Cache Successfully Cleared!', icon='default', sound=notificationSound) except: log_utils.error() pass
def clearViews(): try: skin = control.skin control.hide() yes = control.yesnoDialog(control.lang(32056), '', '') 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: log_utils.error() pass try: kodiDB = control.transPath('special://home/userdata/Database') kodiViewsDB = control.joinPath(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: log_utils.error() 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=(control.setting('notification.sound') == 'true')) except: log_utils.error() pass
def getTVmaze(self, url, idx=True): from resources.lib.indexers import tvmaze self.list = [] try: try: url = getattr(self, url + '_link') except: pass self.list = cache.get(tvmaze.tvshows().tvmaze_list, 168, url) # if idx: self.worker() ## TVMaze has it's own full list builder. if self.list is None: self.list = [] if idx: self.tvshowDirectory(self.list) return self.list except: from resources.lib.modules import log_utils log_utils.error() if not self.list: control.hide() if self.notifications: control.notification(title=32002, message=33049)
def account_info_to_dialog(self): if not self.api_key: return from resources.lib.windows.textviewer import TextViewerXML try: control.busy() url = (self.base_link + self.account_info_link % (self.api_key)) account_info = requests.get(url, timeout=20).json() if not account_info: control.hide() return control.notification(message=32221, icon=en_icon) account_type = account_info['premium']['name'] month_time_left = float(account_info['premium']['bw_month_time_left']) / 60 / 60 / 24 try: total_time_left = float(account_info['premium']['time_left']) / 60 / 60 / 24 except: total_time_left = '' try: renewal_date = account_info['premium']['to_dt'] except: renewal_date = '' try: is_not_last_month = account_info['premium']['is_not_last_month'] except: is_not_last_month = '' try: bw_used_month = float(account_info['premium']['bw_used_month']) / 1073741824 except: bw_used_month = '' try: bw_limit_month = float(account_info['premium']['bw_limit_month']) / 1073741824 except: bw_limit_month = '' try: rem_bw_limit_month = bw_limit_month - bw_used_month except: rem_bw_limit_month = '' body = [] append = body.append append(getLS(32489) % account_type.upper()) # Account append(getLS(32490) % str(round(bw_limit_month, 0))) # Monthly Limit append(getLS(32491)) # Current Month append(' - %s' % getLS(32492) % str(round(month_time_left, 2))) # Days Remaining append(' - %s GB' % getLS(32493) % str(round(bw_used_month, 2))) # Data Used append(' - %s GB' % getLS(32494) % str(round(rem_bw_limit_month, 2))) # Data Remaining if not account_type == 'LIFETIME': append(getLS(32495)) # Current Subscription append('[B] - %s' % getLS(32492) % str(round(total_time_left, 0))) # Days Remaining if is_not_last_month == '1': append(' - %s' % getLS(32496) % renewal_date) # Resets On else: append(' - %s' % getLS(32497) % renewal_date) # Renewal Needed On control.hide() windows = TextViewerXML('textviewer.xml', control.addonPath(control.addonId()), heading='[B]FURK[/B]', text='\n\n'.join(body)) windows.run() del windows except: from resources.lib.modules import log_utils log_utils.error()
def get(self, url, idx=True, create_directory=True): self.list = [] try: try: url = getattr(self, url + '_link') except: pass try: u = urlparse(url).netloc.lower() except: pass if u in self.trakt_link and '/users/' in url: try: isTraktHistory = (url.split('&page=')[0] in self.trakthistory_link) if '/users/me/' not in url: raise Exception() if trakt.getActivity() > cache.timeout(self.trakt_list, url, self.trakt_user): raise Exception() self.list = cache.get(self.trakt_list, 720, url, self.trakt_user) if isTraktHistory: for i in range(len(self.list)): self.list[i]['traktHistory'] = True except: self.list = cache.get(self.trakt_list, 0, url, self.trakt_user) if isTraktHistory: for i in range(len(self.list)): self.list[i]['traktHistory'] = True if idx: self.worker() if url == self.traktwatchlist_link: self.sort(type='movies.watchlist') else: if not isTraktHistory: self.sort() elif u in self.trakt_link and self.search_link in url: self.list = cache.get(self.trakt_list, 6, url, self.trakt_user) if idx: self.worker(level=0) elif u in self.trakt_link: self.list = cache.get(self.trakt_list, 24, url, self.trakt_user) if idx: self.worker() elif u in self.imdb_link and ('/user/' in url or '/list/' in url): isRatinglink = True if self.imdbratings_link in url else False self.list = cache.get(self.imdb_list, 0, url, isRatinglink) if idx: self.worker() elif u in self.imdb_link: self.list = cache.get(self.imdb_list, 96, url) if idx: self.worker() if self.list is None: self.list = [] if idx and create_directory: self.movieDirectory(self.list) return self.list except: log_utils.error() if not self.list: control.hide() if self.notifications: control.notification(title=32001, message=33049)
def clearMetaAndCache(self): control.hide() if not control.yesnoDialog(getLS(35531), '', ''): return try: def cache_clear_both(): try: from resources.lib.database import cache, metacache metacache.cache_clear_meta() cache.cache_clear() return True except: from resources.lib.modules import log_utils log_utils.error() if cache_clear_both(): control.notification(message=35532) else: control.notification(message=33586) except: from resources.lib.modules import log_utils log_utils.error()
def clearViews(): try: skin = control.skin control.hide() if not control.yesnoDialog(control.lang(32056), '', ''): return control.makeFile(control.dataPath) dbcon = db.connect(control.viewsFile) dbcur = dbcon.cursor() try: dbcur.execute('''DROP TABLE IF EXISTS views''') 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() except: from resources.lib.modules import log_utils log_utils.error() finally: dbcur.close() dbcon.close() try: kodiDB = control.transPath('special://home/userdata/Database') kodiViewsDB = control.joinPath(kodiDB, 'ViewModes6.db') dbcon = db.connect(kodiViewsDB) dbcur = dbcon.cursor() dbcur.execute( '''DELETE FROM view WHERE path LIKE "plugin://plugin.video.dg/%"''' ) dbcur.connection.commit() except: from resources.lib.modules import log_utils log_utils.error() finally: dbcur.close() dbcon.close() skinName = control.addon(skin).getAddonInfo('name') skinIcon = control.addon(skin).getAddonInfo('icon') control.notification(title=skinName, message=32087, icon=skinIcon) except: from resources.lib.modules import log_utils log_utils.error()
def moviesListToLibrary(self, url): url = getattr(self, url + '_link') u = urlparse(url).netloc.lower() try: control.hide() if u in self.tmdb_link: items = tmdb_indexer.userlists(url) elif u in self.trakt_link: items = self.trakt_user_list(url, self.trakt_user) items = [(i['name'], i['url']) for i in items] message = 32663 if 'themoviedb' in url: message = 32681 select = control.selectDialog([i[0] for i in items], control.lang(message)) list_name = items[select][0] if select == -1: return link = items[select][1] link = link.split('&sort_by')[0] from resources.lib.modules import library library.libmovies().range(link, list_name) except: log_utils.error() return
def getTMDb(self, url, idx=True, cached=True): self.list = [] try: try: url = getattr(self, url + '_link') except: pass try: u = urlparse(url).netloc.lower() except: pass if u in self.tmdb_link and '/list/' in url: self.list = cache.get(tmdb_indexer.TVshows().tmdb_collections_list, 0, url) elif u in self.tmdb_link and not '/list/' in url: duration = 168 if cached else 0 self.list = cache.get(tmdb_indexer.TVshows().tmdb_list, duration, url) if self.list is None: self.list = [] if idx: self.tvshowDirectory(self.list) return self.list except: from resources.lib.modules import log_utils log_utils.error() if not self.list: control.hide() if self.notifications: control.notification(title=32002, message=33049)
def clearCacheAll(self): control.hide() if not control.yesnoDialog(getLS(32077), '', ''): return try: def cache_clear_all(): try: from resources.lib.database import cache, providerscache, metacache providerscache.cache_clear_providers() metacache.cache_clear_meta() cache.cache_clear() cache.cache_clear_search() # cache.cache_clear_bookmarks() return True except: from resources.lib.modules import log_utils log_utils.error() if cache_clear_all(): control.notification(message=32089) else: control.notification(message=33586) except: from resources.lib.modules import log_utils log_utils.error()
def get(self, url, idx=True, create_directory=True): self.list = [] try: try: url = getattr(self, url + '_link') except: pass try: u = urlparse(url).netloc.lower() except: pass if u in self.trakt_link and '/users/' in url: try: if '/users/me/' not in url: raise Exception() if trakt.getActivity() > cache.timeout(self.trakt_list, url, self.trakt_user): raise Exception() self.list = cache.get(self.trakt_list, 720, url, self.trakt_user) except: self.list = cache.get(self.trakt_list, 0, url, self.trakt_user) if idx: self.worker() if url == self.traktwatchlist_link: self.sort(type='shows.watchlist') else: self.sort() elif u in self.trakt_link and self.search_link in url: self.list = cache.get(self.trakt_list, 1, url, self.trakt_user) if idx: self.worker(level=0) elif u in self.trakt_link: self.list = cache.get(self.trakt_list, 24, url, self.trakt_user) if idx: self.worker() elif u in self.imdb_link and ('/user/' in url or '/list/' in url): isRatinglink=True if self.imdbratings_link in url else False self.list = cache.get(self.imdb_list, 0, url, isRatinglink) if idx: self.worker() # self.sort() # switched to request sorting for imdb elif u in self.imdb_link: self.list = cache.get(self.imdb_list, 96, url) if idx: self.worker() if self.list is None: self.list = [] if create_directory: self.tvshowDirectory(self.list) return self.list except: from resources.lib.modules import log_utils log_utils.error() if not self.list: control.hide() if self.notifications: control.notification(title=32002, message=33049)
def add_uncached_torrent(self, magnet_url, pack=False): def _return_failed(message=control.lang(33586)): try: control.progressDialog.close() except: pass self.delete_transfer(transfer_id) control.hide() control.sleep(500) control.okDialog(title=control.lang(40018), message=message) return False control.busy() transfer_id = self.create_transfer(magnet_url) if not transfer_id: return _return_failed() transfer_info = self.list_transfer(transfer_id) if not transfer_info: return _return_failed() if pack: control.hide() control.okDialog(title='default', message=control.lang(40017) % control.lang(40059)) return True interval = 5 line1 = '%s...' % (control.lang(40017) % control.lang(40059)) line2 = transfer_info['filename'] line3 = transfer_info['status'] control.progressDialog.create(control.lang(40018), line1, line2, line3) while not transfer_info['statusCode'] == 4: control.sleep(1000 * interval) transfer_info = self.list_transfer(transfer_id) file_size = transfer_info['size'] line2 = transfer_info['filename'] if transfer_info['statusCode'] == 1: download_speed = round(float(transfer_info['downloadSpeed']) / (1000**2), 2) progress = int(float(transfer_info['downloaded']) / file_size * 100) if file_size > 0 else 0 line3 = control.lang(40016) % (download_speed, transfer_info['seeders'], progress, round(float(file_size) / (1000 ** 3), 2)) elif transfer_info['statusCode'] == 3: upload_speed = round(float(transfer_info['uploadSpeed']) / (1000 ** 2), 2) progress = int(float(transfer_info['uploaded']) / file_size * 100) if file_size > 0 else 0 line3 = control.lang(40015) % (upload_speed, progress, round(float(file_size) / (1000 ** 3), 2)) else: line3 = transfer_info['status'] progress = 0 control.progressDialog.update(progress, line2=line2, line3=line3) if control.monitor.abortRequested(): return sys.exit() try: if control.progressDialog.iscanceled(): if control.yesnoDialog('Delete AD download also?', 'No will continue the download', 'but close dialog'): return _return_failed(control.lang(40014)) else: control.progressDialog.close() control.hide() return False except: pass if 5 <= transfer_info['statusCode'] <= 10: return _return_failed() control.sleep(1000 * interval) try: control.progressDialog.close() except: pass control.hide() return True
def views(self): try: syshandle = int(argv[1]) control.hide() items = [(control.lang(32001), 'movies'), (control.lang(32002), 'tvshows'), (control.lang(32054), 'seasons'), (control.lang(32038), 'episodes')] select = control.selectDialog([i[0] for i in items], control.lang(32049)) if select == -1: return content = items[select][1] title = control.lang(32059) url = '%s?action=tools_addView&content=%s' % (argv[0], content) poster, banner, fanart = control.addonPoster( ), control.addonBanner(), control.addonFanart() try: item = control.item(label=title, offscreen=True) except: item = control.item(label=title) item.setInfo(type='video', infoLabels={'title': title}) item.setArt({ 'icon': poster, 'thumb': poster, 'poster': poster, 'fanart': fanart, 'banner': banner }) item.setProperty('IsPlayable', 'false') control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) control.content(syshandle, content) control.directory(syshandle, cacheToDisc=True) from resources.lib.modules import views views.setView(content, {}) except: log_utils.error() return
def furk_meta_search(self, url): if self.api_key == '': return '' control.busy() try: s = requests.Session() url = (self.base_link + self.search_link % (self.api_key, url)).replace(' ', '+') # url = (self.base_link + self.search_link % (self.api_key, url, 'extended', 'full', '')).replace(' ', '+') p = s.get(url) p = json.loads(p.text) files = p['files'] except: log_utils.error() return '' for i in files: try: name = control.strip_non_ascii_and_unprintable(i['name']) url_dl = '' for x in accepted_extensions: if 'url_dl' in i: if i['url_dl'].endswith(x): url_dl = i['url_dl'] else: continue else: continue if url_dl == '': continue if not int(i['files_num_video_player']) > 1: if int(i['ss_num']) > 0: thumb = i['ss_urls'][0] else: thumb = '' self.addDirectoryItem(name, url_dl, thumb, '', False) else: # self.addDirectoryItem(i['name'].encode('utf-8'), i['url_dl'], '', '') continue except: log_utils.error() control.hide() self.endDirectory() return ''
def _rating(action, imdb=None, tvdb=None, season=None, episode=None): control.busy() try: addon = 'script.trakt' if control.condVisibility('System.HasAddon(%s)' % addon): import imp # from importlib import import_module ? data = {} data['action'] = action if tvdb: data['video_id'] = tvdb if episode: data['media_type'] = 'episode' data['dbid'] = 1 data['season'] = int(season) data['episode'] = int(episode) elif season: data['media_type'] = 'season' data['dbid'] = 5 data['season'] = int(season) else: data['media_type'] = 'show' data['dbid'] = 2 else: data['video_id'] = imdb data['media_type'] = 'movie' data['dbid'] = 4 script = control.joinPath(control.addonPath(addon), 'resources', 'lib', 'sqlitequeue.py') sqlitequeue = imp.load_source('sqlitequeue', script) # this may be deprecated data = {'action': 'manualRating', 'ratingData': data} sqlitequeue.SqliteQueue().append(data) else: control.notification(title=32315, message=33659) control.hide() except: log_utils.error()