def tvshows(tvshowtitle, imdb, tvdb, season, watched):
    control.busy()
    try:
        import sys,xbmc

        if not trakt.getTraktIndicatorsInfo() == False: raise Exception()

        from metahandler import metahandlers
        from resources.lib.indexers import episodes

        metaget = metahandlers.MetaData(preparezip=False)

        name = control.addonInfo('name')

        dialog = control.progressDialogBG
        dialog.create(str(name), str(tvshowtitle))
        dialog.update(0, str(name), str(tvshowtitle))

        metaget.get_meta('tvshow', name='', imdb_id=imdb)

        items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False)
        try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))]
        except: pass
        items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items]

        for i in range(len(items)):
            if xbmc.abortRequested == True: return sys.exit()

            dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label']))

            season, episode = items[i]['season'], items[i]['episode']
            metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
            metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched))

        try: dialog.close()
        except: pass
    except:
        try: dialog.close()
        except: pass


    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()

        if season:
            from resources.lib.indexers import episodes
            items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, season, idx=False)
            items = [(int(i['season']), int(i['episode'])) for i in items]
            items = [i[1] for i in items if int('%01d' % int(season)) == int('%01d' % i[0])]
            for i in items:
                if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, i)
                else: trakt.markEpisodeAsNotWatched(tvdb, season, i)
        else:
            if int(watched) == 7: trakt.markTVShowAsWatched(tvdb)
            else: trakt.markTVShowAsNotWatched(tvdb)
        trakt.cachesyncTVShows()
    except:
        pass

    control.refresh()
Exemplo n.º 2
0
def tvshows(tvshowtitle, imdb, tvdb, season, watched):
    control.busy()
    try:
        import sys,xbmc

        if not trakt.getTraktIndicatorsInfo() == False: raise Exception()

        from metahandler import metahandlers
        from resources.lib.indexers import episodes

        metaget = metahandlers.MetaData(preparezip=False)

        name = control.addonInfo('name')

        dialog = control.progressDialogBG
        dialog.create(str(name), str(tvshowtitle))
        dialog.update(0, str(name), str(tvshowtitle))

        metaget.get_meta('tvshow', name='', imdb_id=imdb)

        items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False)
        try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))]
        except: pass
        items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items]

        for i in range(len(items)):
            if xbmc.abortRequested == True: return sys.exit()

            dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label']))

            season, episode = items[i]['season'], items[i]['episode']
            metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
            metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched))

        try: dialog.close()
        except: pass
    except:
        try: dialog.close()
        except: pass


    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()

        if season:
            from resources.lib.indexers import episodes
            items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, season, idx=False)
            items = [(int(i['season']), int(i['episode'])) for i in items]
            items = [i[1] for i in items if int('%01d' % int(season)) == int('%01d' % i[0])]
            for i in items:
                if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, i)
                else: trakt.markEpisodeAsNotWatched(tvdb, season, i)
        else:
            if int(watched) == 7: trakt.markTVShowAsWatched(tvdb)
            else: trakt.markTVShowAsNotWatched(tvdb)
        trakt.cachesyncTVShows()
    except:
        pass

    control.refresh()
Exemplo n.º 3
0
def episodes(imdb, tvdb, season, episode, watched):
    control.busy()
    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()
        if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, episode)
        else: trakt.markEpisodeAsNotWatched(tvdb, season, episode)
        trakt.cachesyncTVShows()
        control.refresh()
    except:
        pass

    try:
        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)
        metaget.get_meta('tvshow', name='', imdb_id=imdb)
        metaget.get_episode_meta('',
                                 imdb_id=imdb,
                                 season=season,
                                 episode=episode)
        metaget.change_watched('episode',
                               '',
                               imdb_id=imdb,
                               season=season,
                               episode=episode,
                               watched=int(watched))
        if trakt.getTraktIndicatorsInfo() == False: control.refresh()
    except:
        pass
Exemplo n.º 4
0
	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
Exemplo n.º 5
0
def movies(imdb, watched):
    control.busy()
    try:
        if trakt.getTraktIndicatorsInfo() == False:
            raise Exception()
        if int(watched) == 7:
            trakt.markMovieAsWatched(imdb)
        else:
            trakt.markMovieAsNotWatched(imdb)
        trakt.cachesyncMovies()
        control.refresh()
        control.idle()
    except:
        pass
    try:
        from metahandler import metahandlers
        metaget = metahandlers.MetaData()  # (preparezip=False)
        metaget.get_meta('movie', name='', imdb_id=imdb)
        metaget.change_watched('movie',
                               name='',
                               imdb_id=imdb,
                               watched=int(watched))
        if trakt.getTraktIndicatorsInfo() == False:
            control.refresh()
            control.idle()
    except:
        pass
Exemplo n.º 6
0
	def add_uncached_torrent(self, magnet_url, pack=False):
		def _transfer_info(transfer_id):
			info = self.list_transfer()
			if 'status' in info and info['status'] == 'success':
				for item in info['transfers']:
					if item['id'] == transfer_id: return item
			return {}
		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()
		extensions = supported_video_extensions()
		transfer_id = self.create_transfer(magnet_url)
		if not transfer_id: 	return control.hide()
		if not transfer_id['status'] == 'success': return _return_failed()
		transfer_id = transfer_id['id']
		transfer_info = _transfer_info(transfer_id)
		if not transfer_info: return _return_failed()
		# if pack:
			# control.hide()
			# control.okDialog(title='default', message=control.lang(40017) % control.lang(40057))
			# return True
		interval = 5
		line = '%s\n%s\n%s'
		line1 = '%s...' % (control.lang(40017) % control.lang(40057))
		line2 = transfer_info['name']
		line3 = transfer_info['message']
		control.progressDialog.create(control.lang(40018), line % (line1, line2, line3))
		while not transfer_info['status'] == 'seeding':
			control.sleep(1000 * interval)
			transfer_info = _transfer_info(transfer_id)
			line3 = transfer_info['message']
			control.progressDialog.update(int(float(transfer_info['progress']) * 100), line % (line1, line2, line3))
			if control.monitor.abortRequested(): return sysexit()
			try:
				if control.progressDialog.iscanceled():
					if control.yesnoDialog('Delete PM 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 transfer_info.get('status') == 'stalled':
				return _return_failed()
		control.sleep(1000 * interval)
		try:
			control.progressDialog.close()
		except:
			log_utils.error()
		control.hide()
		return True
Exemplo n.º 7
0
def download(title, img, url):
    from resources.lib.modules import control
    control.busy()
    import json

    if url is None:
        return

    try:
        import resolveurl
        url = resolveurl.resolve(url)
    except Exception:
        control.idle()
        xbmcgui.Dialog().ok(NAME, 'Download failed', 'Your service can\'t resolve this hoster', 'or Link is down')
        return
    try:
        headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1]))
    except:
        headers = dict('')

    content = re.compile('(.+?)\s+[\.|\(|\[]S(\d+)E\d+[\.|\)|\]]', re.I).findall(title)
    transname = title.translate(None, '\/:*?"<>|').strip('.')
    transname = re.sub('\[.+?\]', '', transname)
    levels =['../../../..', '../../..', '../..', '..']

    if len(content) == 0:
        dest = control.setting('movie.download.path')
        dest = control.transPath(dest)
        for level in levels:
            try: control.makeFile(os.path.abspath(os.path.join(dest, level)))
            except: pass
        control.makeFile(dest)
        dest = os.path.join(dest, transname)
        control.makeFile(dest)
    else:
        dest = control.setting('tv.download.path')
        dest = control.transPath(dest)
        for level in levels:
            try: control.makeFile(os.path.abspath(os.path.join(dest, level)))
            except: pass
        control.makeFile(dest)
        tvtitle = re.sub('\[.+?\]', '', content[0])
        transtvshowtitle = tvtitle.translate(None, '\/:*?"<>|').strip('.')
        dest = os.path.join(dest, transtvshowtitle)
        control.makeFile(dest)
        dest = os.path.join(dest, 'Season %01d' % int(content[0][1]))
        control.makeFile(dest)

    ext = os.path.splitext(urlparse.urlparse(url).path)[1][1:]
    if not ext in ['mp4', 'mkv', 'flv', 'avi', 'mpg']: ext = 'mp4'
    dest = os.path.join(dest, transname + '.' + ext)
    headers = urllib.quote_plus(json.dumps(headers))

    from resources.lib.modules import downloader
    control.idle()
    downloader.doDownload(url, dest, title, img, headers)
Exemplo n.º 8
0
def Del_search(url):
    control.busy()
    search = url.split('s=')[1].decode('utf-8')

    dbcon = database.connect(control.searchFile)
    dbcur = dbcon.cursor()
    dbcur.execute("DELETE FROM Search WHERE search = ?", (search, ))
    dbcon.commit()
    dbcur.close()
    xbmc.executebuiltin('Container.Refresh')
    control.idle()
Exemplo n.º 9
0
def del_search(query):
    control.busy()
    #xbmc.log('$#$DEL-search:%s' % query, xbmc.LOGNOTICE)
    search = urllib.quote_plus(query)

    dbcon = database.connect(control.searchFile)
    dbcur = dbcon.cursor()
    dbcur.execute("DELETE FROM Search WHERE search = ?", (search, ))
    dbcon.commit()
    dbcur.close()
    control.refresh()
    control.idle()
Exemplo n.º 10
0
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()
Exemplo n.º 11
0
def playlistManager(name = None, url = None, meta = None, art = None):
    try:
        items = []
        items += [(control.lang(32065).encode('utf-8'), 'playlistAdd')]
        items += [(control.lang(35518).encode('utf-8'), 'playlistRemove')]
        items += [(control.lang(35517).encode('utf-8'), 'playlistShow')]
        items += [(control.lang(35516).encode('utf-8'), 'playlistClear')]

        control.hide()
        select = control.selectDialog([i[0] for i in items], heading = control.addonInfo('name') + ' - ' + control.lang(35522).encode('utf-8'))

        if select == -1:
            return
        if select >= 0:
            if select == 0:
                control.busy()
                playlistAdd(name, url, meta, art)
                control.hide()
            elif select == 1:
                control.busy()
                playlistRemove(name)
                control.hide()
            elif select == 2:
                control.busy()
                playlistShow()
                control.hide()
            elif select == 3:
                control.busy()
                playlistClear()
                control.hide()
    except:
        import traceback
        traceback.print_exc()
        control.hide()
Exemplo n.º 12
0
def playlistManager(name=None, url=None, meta=None, art=None):
    try:
        items = []
        items += [(control.lang(32065), 'playlistAdd')]
        items += [(control.lang(35518), 'playlistRemove')]
        items += [(control.lang(35517), 'playlistShow')]
        items += [(control.lang(35516), 'playlistClear')]
        control.hide()
        select = control.selectDialog([i[0] for i in items],
                                      heading=control.addonInfo('name') +
                                      ' - ' + control.lang(35522))
        if select == -1:
            return
        if select >= 0:
            if select == 0:
                control.busy()
                playlistAdd(name, url, meta, art)
                control.hide()
            elif select == 1:
                control.busy()
                playlistRemove(name)
                control.hide()
            elif select == 2:
                control.busy()
                playlistShow()
                control.hide()
            elif select == 3:
                control.busy()
                playlistClear()
                control.hide()
    except:
        log_utils.error()
        control.hide()
Exemplo n.º 13
0
def Del_search(url):
    control.busy()
    search = url.split('s=')[1].decode('utf-8')

    try:
        from sqlite3 import dbapi2 as database
    except ImportError:
        from pysqlite2 import dbapi2 as database

    dbcon = database.connect(control.searchFile)
    dbcur = dbcon.cursor()
    dbcur.execute("DELETE FROM Search WHERE search = ?", (search, ))
    dbcon.commit()
    dbcur.close()
    xbmc.executebuiltin('Container.Refresh')
    control.idle()
Exemplo n.º 14
0
	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()
Exemplo n.º 15
0
def movies(imdb, watched):
    control.busy()
    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()
        if int(watched) == 7: trakt.markMovieAsWatched(imdb)
        else: trakt.markMovieAsNotWatched(imdb)
        trakt.cachesyncMovies()
        control.refresh()
    except:
        pass

    try:
        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)
        metaget.get_meta('movie', name='', imdb_id=imdb)
        metaget.change_watched('movie', name='', imdb_id=imdb, watched=int(watched))
        if trakt.getTraktIndicatorsInfo() == False: control.refresh()
    except:
        pass
Exemplo n.º 16
0
def episodes(imdb, tvdb, season, episode, watched):
    control.busy()
    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()
        if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, episode)
        else: trakt.markEpisodeAsNotWatched(tvdb, season, episode)
        trakt.cachesyncTVShows()
        control.refresh()
    except:
        pass

    try:
        from metahandler import metahandlers
        metaget = metahandlers.MetaData(preparezip=False)
        metaget.get_meta('tvshow', name='', imdb_id=imdb)
        metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
        metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched))
        if trakt.getTraktIndicatorsInfo() == False: control.refresh()
    except:
        pass
Exemplo n.º 17
0
 def account_info_to_dialog(self):
     from datetime import datetime
     import time
     from resources.lib.windows.textviewer import TextViewerXML
     try:
         control.busy()
         account_info, usage_info = self.account()
         if not account_info or not usage_info:
             control.hide()
             return control.notification(message=32221, icon=en_icon)
         expires = datetime.fromtimestamp(
             time.mktime(time.strptime(account_info[2], '%Y-%m-%d')))
         days_remaining = (expires - datetime.today()).days
         expires = expires.strftime('%Y-%m-%d')
         body = []
         append = body.append
         append(getLS(40036) % account_info[0])  # Username
         append(getLS(40066) % account_info[1])  # Plan
         append(getLS(40037) % account_info[3])  # Status
         append(getLS(40041) % expires)  # Expires
         append(getLS(40042) % days_remaining)  # Days Remaining
         append(getLS(32218) % usage_info[2])  # Loyalty
         append(getLS(32219) %
                usage_info[0].replace('Gigs', 'GB'))  # Data Used
         append(
             getLS(32220) % re.sub(r'[</].+?>', '', usage_info[1].replace(
                 'Gigs', 'GB')))  # Data Remaining
         control.hide()
         windows = TextViewerXML('textviewer.xml',
                                 control.addonPath(control.addonId()),
                                 heading='[B]EasyNews[/B]',
                                 text='\n\n'.join(body))
         windows.run()
         del windows
     except:
         from resources.lib.modules import log_utils
         log_utils.error()
         control.hide()
Exemplo n.º 18
0
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()
Exemplo n.º 19
0
    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 ''
Exemplo n.º 20
0
def Search_gamato(url):  # 18
    control.busy()
    data = r = requests.get(url).text
    posts = client.parseDOM(data, 'div', attrs={'class': 'result-item'})
    for post in posts:
        link = client.parseDOM(post, 'a', ret='href')[0]
        poster = client.parseDOM(post, 'img',
                                 ret='src')[0].encode('utf-8', 'ignore')
        title = client.parseDOM(post, 'img', ret='alt')[0]
        title = clear_Title(title)
        try:
            year = client.parseDOM(post, 'span', attrs={'class': 'year'})[0]
            desc = client.parseDOM(post, 'div', attrs={'class':
                                                       'contenido'})[0]
            desc = re.sub('<.+?>', '', desc)
            desc = desc.encode('utf-8', 'ignore')
        except IndexError:
            year = 'N/A'
            desc = 'N/A'

        addDir('[B][COLOR white]{0} [{1}][/COLOR][/B]'.format(title, year),
               link, 12, poster, FANART, str(desc))

    try:
        np = client.parseDOM(data,
                             'a',
                             ret='href',
                             attrs={'class': 'arrow_pag'})[-1]
        page = np.split('/')[-1]
        title = '[B][COLORgold]>>>' + Lang(32011).encode(
            'utf-8'
        ) + ' [COLORwhite]([COLORlime]%s[/COLOR])[/COLOR][/B]' % page
        addDir(title, np, 4, ART + 'next.jpg', FANART, '')
    except IndexError:
        pass
    control.idle()
    views.selectView('movies', 'movie-view')
Exemplo n.º 21
0
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
    control.busy()
    section = sections[selection]
    if episode: post = {"shows": [{"ids": {"tvdb": tvdb}}]}
    else: post = {"movies": [{"ids": {"imdb": imdb}}]}
    getTrakt('users/hidden/%s' % section, post=post)[0]
    control.hide()
    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]))
Exemplo n.º 22
0
def routing(_argv):

    params = dict(urllib_parse.parse_qsl(_argv.replace('?', '')))

    action = params.get('action')

    name = params.get('name')

    title = params.get('title')

    year = params.get('year')

    imdb = params.get('imdb')

    tvdb = params.get('tvdb')

    tmdb = params.get('tmdb')

    season = params.get('season')

    episode = params.get('episode')

    tvshowtitle = params.get('tvshowtitle')

    premiered = params.get('premiered')

    url = params.get('url')

    image = params.get('image')

    meta = params.get('meta')

    select = params.get('select')

    query = params.get('query')

    source = params.get('source')

    content = params.get('content')

    status = params.get('status')

    rtype = params.get('rtype')

    windowedtrailer = params.get('windowedtrailer')
    windowedtrailer = int(windowedtrailer) if windowedtrailer in ('0',
                                                                  '1') else 0

    if action == None:
        from resources.lib.indexers import navigator
        from resources.lib.modules import cache
        cache.cache_version_check()
        navigator.navigator().root()

    elif action == 'furkNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().furk()

    elif action == 'furkMetaSearch':
        from resources.lib.indexers import furk
        furk.furk().furk_meta_search(url)

    elif action == 'furkSearch':
        from resources.lib.indexers import furk
        furk.furk().search()

    elif action == 'furkUserFiles':
        from resources.lib.indexers import furk
        furk.furk().user_files()

    elif action == 'furkSearchNew':
        from resources.lib.indexers import furk
        furk.furk().search_new()

    elif action == 'movieNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().movies()

    elif action == 'movieliteNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().movies(lite=True)

    elif action == 'mymovieNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().mymovies()

    elif action == 'mymovieliteNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().mymovies(lite=True)

    elif action == 'tvNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().tvshows()

    elif action == 'tvliteNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().tvshows(lite=True)

    elif action == 'mytvNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().mytvshows()

    elif action == 'mytvliteNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().mytvshows(lite=True)

    elif action == 'downloadNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().downloads()

    elif action == 'libraryNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().library()

    elif action == 'toolNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().tools()

    elif action == 'searchNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().search()

    elif action == 'viewsNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().views()

    elif action == 'cacheNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().cache_functions()

    elif action == 'logNavigator':
        from resources.lib.indexers import navigator
        navigator.navigator().log_functions()

    elif action == 'clearCache':
        from resources.lib.indexers import navigator
        navigator.navigator().clearCache()

    elif action == 'clearCacheProviders':
        from resources.lib.indexers import navigator
        navigator.navigator().clearCacheProviders()

    elif action == 'clearDebridCheck':
        from resources.lib.indexers import navigator
        navigator.navigator().clearDebridCheck()

    elif action == 'clearCacheSearch':
        from resources.lib.indexers import navigator
        navigator.navigator().clearCacheSearch(select)

    elif action == 'clearAllCache':
        from resources.lib.indexers import navigator
        navigator.navigator().clearCacheAll()

    elif action == 'infoCheck':
        from resources.lib.indexers import navigator
        navigator.navigator().infoCheck('')

    elif action == 'uploadLog':
        from resources.lib.indexers import navigator
        navigator.navigator().uploadLog()

    elif action == 'emptyLog':
        from resources.lib.indexers import navigator
        navigator.navigator().emptyLog()

    elif action == 'viewLog':
        from resources.lib.modules import log_utils
        log_utils.view_log()

    elif action == 'movies':
        from resources.lib.indexers import movies
        movies.movies().get(url)

    elif action == 'moviePage':
        from resources.lib.indexers import movies
        movies.movies().get(url)

    elif action == 'movieWidget':
        from resources.lib.indexers import movies
        movies.movies().widget()

    elif action == 'movieSearch':
        from resources.lib.indexers import movies
        movies.movies().search()

    elif action == 'movieSearchnew':
        from resources.lib.indexers import movies
        movies.movies().search_new()

    elif action == 'movieSearchterm':
        from resources.lib.indexers import movies
        movies.movies().search_term(name)

    elif action == 'movieMosts':
        from resources.lib.indexers import movies
        movies.movies().mosts()

    elif action == 'movieGenres':
        from resources.lib.indexers import movies
        movies.movies().genres()

    elif action == 'movieLanguages':
        from resources.lib.indexers import movies
        movies.movies().languages()

    elif action == 'movieCertificates':
        from resources.lib.indexers import movies
        movies.movies().certifications()

    elif action == 'movieYears':
        from resources.lib.indexers import movies
        movies.movies().years()

    elif action == 'movieDecades':
        from resources.lib.indexers import movies
        movies.movies().decades()

    elif action == 'movieKeywords':
        from resources.lib.indexers import movies
        movies.movies().keywords()

    elif action == 'movieKeywords2':
        from resources.lib.indexers import movies
        movies.movies().keywords2()

    elif action == 'movieCustomLists':
        from resources.lib.indexers import movies
        movies.movies().custom_lists()

    elif action == 'movieUserlists':
        from resources.lib.indexers import movies
        movies.movies().userlists()

    elif action == 'channels':
        from resources.lib.indexers import channels
        channels.channels().get()

    elif action == 'tvshows':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().get(url)

    elif action == 'tvshowPage':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().get(url)

    elif action == 'tvSearch':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().search()

    elif action == 'tvSearchnew':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().search_new()

    elif action == 'tvSearchterm':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().search_term(name)

    elif action == 'tvMosts':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().mosts()

    elif action == 'tvGenres':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().genres()

    elif action == 'tvNetworks':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().networks()

    elif action == 'tvLanguages':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().languages()

    elif action == 'tvCertificates':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().certifications()

    elif action == 'tvUserlists':
        from resources.lib.indexers import tvshows
        tvshows.tvshows().userlists()

    elif action == 'peopleSearch':
        from resources.lib.indexers import people
        people.People().search(content)

    elif action == 'peopleSearchnew':
        from resources.lib.indexers import people
        people.People().search_new(content)

    elif action == 'peopleSearchterm':
        from resources.lib.indexers import people
        people.People().search_term(name, content)

    elif action == 'persons':
        from resources.lib.indexers import people
        people.People().persons(url, content)

    elif action == 'moviePerson':
        from resources.lib.indexers import people
        people.People().persons(url, content='movies')

    elif action == 'tvPerson':
        from resources.lib.indexers import people
        people.People().persons(url, content='tvshows')

    elif action == 'personsSelect':
        from resources.lib.indexers import people
        people.People().getPeople(name, url)

    elif action == 'seasons':
        from resources.lib.indexers import episodes
        episodes.seasons().get(tvshowtitle, year, imdb, tmdb, meta)

    elif action == 'episodes':
        from resources.lib.indexers import episodes
        episodes.episodes().get(tvshowtitle, year, imdb, tmdb, meta, season,
                                episode)

    elif action == 'calendar':
        from resources.lib.indexers import episodes
        episodes.episodes().calendar(url)

    elif action == 'tvWidget':
        from resources.lib.indexers import episodes
        episodes.episodes().widget()

    elif action == 'calendars':
        from resources.lib.indexers import episodes
        episodes.episodes().calendars()

    elif action == 'episodeUserlists':
        from resources.lib.indexers import episodes
        episodes.episodes().userlists()

    elif action == 'refresh':
        from resources.lib.modules import control
        control.refresh()

    elif action == 'queueItem':
        from resources.lib.modules import control
        control.queueItem()

    elif action == 'openSettings':
        from resources.lib.modules import control
        control.openSettings(query)

    elif action == 'artwork':
        from resources.lib.modules import control
        control.artwork()

    elif action == 'addView':
        from resources.lib.modules import views
        views.addView(content)

    elif action == 'moviePlaycount':
        from resources.lib.modules import playcount
        playcount.movies(imdb, query)

    elif action == 'episodePlaycount':
        from resources.lib.modules import playcount
        playcount.episodes(imdb, tmdb, season, episode, query)

    elif action == 'tvPlaycount':
        from resources.lib.modules import playcount
        playcount.tvshows(name, imdb, tmdb, season, query)

    elif action == 'yt_trailer':
        from resources.lib.modules import control, trailer
        if not control.condVisibility('System.HasAddon(plugin.video.youtube)'):
            control.installAddon('plugin.video.youtube')
        trailer.YT_trailer().play(name, url, tmdb, imdb, season, episode,
                                  windowedtrailer)

    elif action == 'tmdb_trailer':
        from resources.lib.modules import control, trailer
        if not control.condVisibility('System.HasAddon(plugin.video.youtube)'):
            control.installAddon('plugin.video.youtube')
        trailer.TMDb_trailer().play(tmdb, imdb, season, episode,
                                    windowedtrailer)

    elif action == 'imdb_trailer':
        from resources.lib.modules import trailer
        trailer.IMDb_trailer().play(imdb, name, tmdb, season, episode,
                                    windowedtrailer)

    elif action == 'traktManager':
        from resources.lib.modules import trakt
        trakt.manager(name, imdb, tmdb, content)

    elif action == 'authTrakt':
        from resources.lib.modules import trakt
        trakt.authTrakt()

    elif action == 'smuSettings':
        try:
            import resolveurl
            resolveurl.display_settings()
        except:
            pass

    elif action == 'oathscrapersettings':
        from resources.lib.modules import control
        control.openSettings('0.0', 'script.module.oathscrapers')

    elif action == 'installOrion':
        from resources.lib.modules import control
        control.installAddon('script.module.orion')
        control.sleep(200)
        control.refresh()

    elif action == 'orionsettings':
        from resources.lib.modules import control
        control.openSettings('0.0', 'script.module.orion')

    elif action == 'download':
        import simplejson as json
        from resources.lib.modules import sources
        from resources.lib.modules import downloader
        try:
            downloader.download(
                name, image,
                sources.sources().sourcesResolve(json.loads(source)[0], True))
        except:
            pass

    elif action == 'play':
        from resources.lib.modules import control
        control.busy()
        from resources.lib.modules import sources
        sources.sources().play(title,
                               year,
                               imdb,
                               tmdb,
                               season,
                               episode,
                               tvshowtitle,
                               premiered,
                               meta,
                               select,
                               unfiltered=False)

    elif action == 'playUnfiltered':
        from resources.lib.modules import control
        control.busy()
        from resources.lib.modules import sources
        sources.sources().play(title,
                               year,
                               imdb,
                               tmdb,
                               season,
                               episode,
                               tvshowtitle,
                               premiered,
                               meta,
                               select,
                               unfiltered=True)

    elif action == 'addItem':
        from resources.lib.modules import sources
        sources.sources().addItem(title)

    elif action == 'playItem':
        from resources.lib.modules import sources
        sources.sources().playItem(title, source)

    elif action == 'alterSources':
        from resources.lib.modules import sources
        sources.sources().alterSources(url, meta)

    elif action == 'clearSources':
        from resources.lib.modules import sources
        sources.sources().clearSources()

    elif action == 'random':
        from sys import argv
        if rtype == 'movie':
            from resources.lib.indexers import movies
            rlist = movies.movies().get(url, create_directory=False)
            r = argv[0] + '?action=play'
        elif rtype == 'episode':
            from resources.lib.indexers import episodes
            rlist = episodes.episodes().get(tvshowtitle,
                                            year,
                                            imdb,
                                            tmdb,
                                            meta,
                                            season,
                                            create_directory=False)
            r = argv[0] + '?action=play'
        elif rtype == 'season':
            from resources.lib.indexers import episodes
            rlist = episodes.seasons().get(tvshowtitle,
                                           year,
                                           imdb,
                                           tmdb,
                                           None,
                                           create_directory=False)
            r = argv[0] + '?action=random&rtype=episode'
        elif rtype == 'show':
            from resources.lib.indexers import tvshows
            rlist = tvshows.tvshows().get(url, create_directory=False)
            r = argv[0] + '?action=random&rtype=season'
        from random import randint
        import simplejson as json
        try:
            from resources.lib.modules import control
            rand = randint(1, len(rlist)) - 1
            for p in [
                    'title', 'year', 'imdb', 'tmdb', 'season', 'episode',
                    'tvshowtitle', 'premiered', 'select'
            ]:
                if rtype == 'show' and p == 'tvshowtitle':
                    try:
                        r += '&' + p + '=' + urllib_parse.quote_plus(
                            rlist[rand]['title'])
                    except:
                        pass
                else:
                    if rtype == 'movie':
                        rlist[rand]['title'] = rlist[rand]['originaltitle']
                    elif rtype == 'episode':
                        rlist[rand]['tvshowtitle'] = urllib_parse.unquote_plus(
                            rlist[rand]['tvshowtitle'])
                    try:
                        r += '&' + p + '=' + urllib_parse.quote_plus(
                            rlist[rand][p])
                    except:
                        pass
            try:
                r += '&meta=' + urllib_parse.quote_plus(json.dumps(
                    rlist[rand]))
            except:
                r += '&meta={}'
            if rtype == 'movie':
                try:
                    control.infoDialog(
                        '%s (%s)' %
                        (rlist[rand]['title'], rlist[rand]['year']),
                        control.lang(32536),
                        time=20000)
                except:
                    pass
            elif rtype == 'episode':
                try:
                    control.infoDialog(
                        '%s - %01dx%02d . %s' %
                        (urllib_parse.unquote_plus(rlist[rand]['tvshowtitle']),
                         int(rlist[rand]['season']), int(
                             rlist[rand]['episode']), rlist[rand]['title']),
                        control.lang(32536),
                        time=20000)
                except:
                    pass
            control.execute('RunPlugin(%s)' % r)
        except:
            from resources.lib.modules import control
            control.infoDialog(control.lang(32537), time=8000)

    elif action == 'movieToLibrary':
        from resources.lib.modules import libtools
        libtools.libmovies().add(name, title, year, imdb, tmdb)

    elif action == 'moviesToLibrary':
        from resources.lib.modules import libtools
        libtools.libmovies().range(url)

    elif action == 'moviesToLibrarySilent':
        from resources.lib.modules import libtools
        libtools.libmovies().silent(url)

    elif action == 'tvshowToLibrary':
        from resources.lib.modules import libtools
        libtools.libtvshows().add(tvshowtitle, year, imdb, tmdb)

    elif action == 'tvshowsToLibrary':
        from resources.lib.modules import libtools
        libtools.libtvshows().range(url)

    elif action == 'tvshowsToLibrarySilent':
        from resources.lib.modules import libtools
        libtools.libtvshows().silent(url)

    elif action == 'updateLibrary':
        from resources.lib.modules import libtools
        libtools.libepisodes().update(query)

    elif action == 'service':
        from resources.lib.modules import libtools
        libtools.libepisodes().service()

    elif action == 'syncTraktStatus':
        from resources.lib.modules import trakt
        trakt.syncTraktStatus()

    elif action == 'changelog':
        from resources.lib.modules import changelog
        changelog.get()

    elif action == 'cleanSettings':
        from resources.lib.modules import control
        control.clean_settings()

    elif action == 'tvcredits':
        from resources.lib.modules import credits
        credits.Credits().get_tv(tmdb, status)

    elif action == 'moviecredits':
        from resources.lib.modules import credits
        credits.Credits().get_movies(tmdb, status)
Exemplo n.º 23
0
def router(params):
    action = params.get('action')
    id = params.get('id')
    name = params.get('name')
    title = params.get('title')
    year = params.get('year')
    imdb = params.get('imdb')
    tmdb = params.get('tmdb')
    tvdb = params.get('tvdb')
    season = params.get('season')
    episode = params.get('episode')
    tvshowtitle = params.get('tvshowtitle')
    type = params.get('type')
    url = params.get('url')
    query = params.get('query')
    source = params.get('source')

    if action is None:
        from resources.lib.menus import navigator
        isUpdate = control.homeWindow.getProperty('venom.updated')
        if isUpdate == 'true':
            control.execute(
                'RunPlugin(plugin://plugin.video.venom/?action=tools_cleanSettings)'
            )
            control.homeWindow.clearProperty('venom.updated')
            from resources.lib.modules import changelog
            changelog.get()
        navigator.Navigator().root()

    ####################################################
    #---MOVIES
    ####################################################
    elif action == 'movieNavigator':
        from resources.lib.menus import navigator
        navigator.Navigator().movies()

    elif action == 'movieliteNavigator':
        from resources.lib.menus import navigator
        navigator.Navigator().movies(lite=True)

    elif action == 'mymovieNavigator':
        from resources.lib.menus import navigator
        navigator.Navigator().mymovies()

    elif action == 'mymovieliteNavigator':
        from resources.lib.menus import navigator
        navigator.Navigator().mymovies(lite=True)

    elif action == 'movies':
        from resources.lib.menus import movies
        movies.Movies().get(url)

    elif action == 'moviePage':
        from resources.lib.menus import movies
        movies.Movies().get(url)

    elif action == 'tmdbmovies':
        from resources.lib.menus import movies
        movies.Movies().getTMDb(url)

    elif action == 'tmdbmoviePage':
        from resources.lib.menus import movies
        movies.Movies().getTMDb(url)

    elif action == 'movieSearch':
        from resources.lib.menus import movies
        movies.Movies().search()

    elif action == 'movieSearchnew':
        from resources.lib.menus import movies
        movies.Movies().search_new()

    elif action == 'movieSearchterm':
        from resources.lib.menus import movies
        movies.Movies().search_term(name)

    elif action == 'moviePerson':
        from resources.lib.menus import movies
        movies.Movies().person()

    elif action == 'movieGenres':
        from resources.lib.menus import movies
        movies.Movies().genres()

    elif action == 'movieLanguages':
        from resources.lib.menus import movies
        movies.Movies().languages()

    elif action == 'movieCertificates':
        from resources.lib.menus import movies
        movies.Movies().certifications()

    elif action == 'movieYears':
        from resources.lib.menus import movies
        movies.Movies().years()

    elif action == 'moviePersons':
        from resources.lib.menus import movies
        movies.Movies().persons(url)

    elif action == 'moviesUnfinished':
        from resources.lib.menus import movies
        movies.Movies().unfinished(url)

    elif action == 'movieUserlists':
        from resources.lib.menus import movies
        movies.Movies().userlists()

    elif action == 'movies_traktUnfinishedManager':
        from resources.lib.menus import movies
        movies.Movies().unfinishedManager()

    ####################################################
    #---Collections
    ####################################################
    elif action and action.startswith('collections'):
        if action == 'collections_Navigator':
            from resources.lib.menus import collections
            collections.Collections().collections_Navigator()
        elif action == 'collections_Boxset':
            from resources.lib.menus import collections
            collections.Collections().collections_Boxset()
        elif action == 'collections_Kids':
            from resources.lib.menus import collections
            collections.Collections().collections_Kids()
        elif action == 'collections_BoxsetKids':
            from resources.lib.menus import collections
            collections.Collections().collections_BoxsetKids()
        elif action == 'collections_Superhero':
            from resources.lib.menus import collections
            collections.Collections().collections_Superhero()
        elif action == 'collections_MartialArts':
            from resources.lib.menus import collections
            collections.Collections().collections_martial_arts()
        elif action == 'collections_MartialArtsActors':
            from resources.lib.menus import collections
            collections.Collections().collections_martial_arts_actors()
        elif action == 'collections':
            from resources.lib.menus import collections
            collections.Collections().get(url)

    ####################################################
    #---Furk
    ####################################################
    elif action and action.startswith('furk'):
        if action == "furkNavigator":
            from resources.lib.menus import navigator
            navigator.Navigator().furk()
        elif action == "furkUserFiles":
            from resources.lib.menus import furk
            furk.Furk().user_files()
        elif action == "furkMetaSearch":
            from resources.lib.menus import furk
            furk.Furk().furk_meta_search(url)
        elif action == "furkSearch":
            from resources.lib.menus import furk
            furk.Furk().search()
        elif action == "furkSearchNew":
            from resources.lib.menus import furk
            furk.Furk().search_new()

    ####################################################
    # TV Shows
    ####################################################
    # if action and action.startswith('tv_'):
    elif action == 'tvNavigator':
        from resources.lib.menus import navigator
        navigator.Navigator().tvshows()

    elif action == 'tvliteNavigator':
        from resources.lib.menus import navigator
        navigator.Navigator().tvshows(lite=True)

    elif action == 'mytvNavigator':
        from resources.lib.menus import navigator
        navigator.Navigator().mytvshows()

    elif action == 'mytvliteNavigator':
        from resources.lib.menus import navigator
        navigator.Navigator().mytvshows(lite=True)

    elif action == 'tvshows':
        from resources.lib.menus import tvshows
        tvshows.TVshows().get(url)

    elif action == 'tvshowPage':
        from resources.lib.menus import tvshows
        tvshows.TVshows().get(url)

    elif action == 'tmdbTvshows':
        from resources.lib.menus import tvshows
        tvshows.TVshows().getTMDb(url)

    elif action == 'tmdbTvshowPage':
        from resources.lib.menus import tvshows
        tvshows.TVshows().getTMDb(url)

    elif action == 'tvmazeTvshows':
        from resources.lib.menus import tvshows
        tvshows.TVshows().getTVmaze(url)

    elif action == 'tvmazeTvshowPage':
        from resources.lib.menus import tvshows
        tvshows.TVshows().getTVmaze(url)

    elif action == 'tvSearch':
        from resources.lib.menus import tvshows
        tvshows.TVshows().search()

    elif action == 'tvSearchnew':
        from resources.lib.menus import tvshows
        tvshows.TVshows().search_new()

    elif action == 'tvSearchterm':
        from resources.lib.menus import tvshows
        tvshows.TVshows().search_term(name)

    elif action == 'tvPerson':
        from resources.lib.menus import tvshows
        tvshows.TVshows().person()

    elif action == 'tvGenres':
        from resources.lib.menus import tvshows
        tvshows.TVshows().genres()

    elif action == 'tvNetworks':
        from resources.lib.menus import tvshows
        tvshows.TVshows().networks()

    elif action == 'tvLanguages':
        from resources.lib.menus import tvshows
        tvshows.TVshows().languages()

    elif action == 'tvCertificates':
        from resources.lib.menus import tvshows
        tvshows.TVshows().certifications()

    elif action == 'tvPersons':
        from resources.lib.menus import tvshows
        tvshows.TVshows().persons(url)

    elif action == 'tvUserlists':
        from resources.lib.menus import tvshows
        tvshows.TVshows().userlists()

    elif action == 'tvOriginals':
        from resources.lib.menus import tvshows
        tvshows.TVshows().originals()

    elif action == 'shows_traktHiddenManager':
        from resources.lib.menus import tvshows
        tvshows.TVshows().traktHiddenManager()

    ####################################################
    #---SEASONS
    ####################################################
    elif action == 'seasons':
        from resources.lib.menus import seasons
        art = params.get('art')
        seasons.Seasons().get(tvshowtitle, year, imdb, tmdb, tvdb, art)

    ####################################################
    #---EPISODES
    ####################################################
    elif action == 'episodes':
        from resources.lib.menus import episodes
        meta = params.get('meta')
        episodes.Episodes().get(tvshowtitle, year, imdb, tmdb, tvdb, meta,
                                season, episode)

    elif action == 'calendar':
        from resources.lib.menus import episodes
        episodes.Episodes().calendar(url)

    elif action == 'upcomingProgress':
        from resources.lib.menus import episodes
        episodes.Episodes().upcoming_progress(url)

    elif action == 'calendars':
        from resources.lib.menus import episodes
        episodes.Episodes().calendars()

    elif action == 'episodesUnfinished':
        from resources.lib.menus import episodes
        episodes.Episodes().unfinished(url)

    elif action == 'episodesUserlists':
        from resources.lib.menus import episodes
        episodes.Episodes().userlists()

    elif action == 'episodes_traktUnfinishedManager':
        from resources.lib.menus import episodes
        episodes.Episodes().unfinishedManager()

    ####################################################
    #---Premium Services
    ####################################################
    elif action == 'premiumNavigator':
        from resources.lib.menus import navigator
        navigator.Navigator().premium_services()

    elif action and action.startswith('pm_'):
        if action == 'pm_ServiceNavigator':
            from resources.lib.menus import navigator
            navigator.Navigator().premiumize_service()
        elif action == 'pm_AccountInfo':
            from resources.lib.debrid import premiumize
            premiumize.Premiumize().account_info_to_dialog()
        # elif action == 'pm_Authorize':
        # from resources.lib.debrid import premiumize
        # premiumize.Premiumize().auth()
        elif action == 'pm_MyFiles':
            from resources.lib.debrid import premiumize
            premiumize.Premiumize().my_files_to_listItem(id, name)
        elif action == 'pm_Transfers':
            from resources.lib.debrid import premiumize
            premiumize.Premiumize().user_transfers_to_listItem()
        elif action == 'pm_Rename':
            from resources.lib.debrid import premiumize
            premiumize.Premiumize().rename(type, id, name)
        elif action == 'pm_Delete':
            from resources.lib.debrid import premiumize
            premiumize.Premiumize().delete(type, id, name)
        elif action == 'pm_DeleteTransfer':
            from resources.lib.debrid import premiumize
            premiumize.Premiumize().delete_transfer(id, name)
        elif action == 'pm_ClearFinishedTransfers':  # disabled for now till PM fixes
            from resources.lib.debrid import premiumize
            premiumize.Premiumize().clear_finished_transfers()

    elif action and action.startswith('rd_'):
        if action == 'rd_ServiceNavigator':
            from resources.lib.menus import navigator
            navigator.Navigator().realdebrid_service()
        elif action == 'rd_AccountInfo':
            from resources.lib.debrid import realdebrid
            realdebrid.RealDebrid().account_info_to_dialog()
        # elif action == 'rd_Authorize':
        # from resources.lib.debrid import realdebrid
        # realdebrid.RealDebrid().auth()
        elif action == 'rd_UserTorrentsToListItem':
            from resources.lib.debrid import realdebrid
            realdebrid.RealDebrid().user_torrents_to_listItem()
        elif action == 'rd_MyDownloads':
            from resources.lib.debrid import realdebrid
            realdebrid.RealDebrid().my_downloads_to_listItem(int(query))
        elif action == 'rd_BrowseUserTorrents':
            from resources.lib.debrid import realdebrid
            realdebrid.RealDebrid().browse_user_torrents(id)
        elif action == 'rd_DeleteUserTorrent':
            from resources.lib.debrid import realdebrid
            realdebrid.RealDebrid().delete_user_torrent(id, name)
        elif action == 'rd_DeleteDownload':
            from resources.lib.debrid import realdebrid
            realdebrid.RealDebrid().delete_download(id, name)

    elif action and action.startswith('ad_'):
        if action == 'ad_ServiceNavigator':
            from resources.lib.menus import navigator
            navigator.Navigator().alldebrid_service()
        elif action == 'ad_AccountInfo':
            from resources.lib.debrid import alldebrid
            alldebrid.AllDebrid().account_info_to_dialog()
        # elif action == 'ad_Authorize':
        # from resources.lib.debrid import alldebrid
        # alldebrid.AllDebrid().auth()
        elif action == 'ad_Transfers':
            from resources.lib.debrid import alldebrid
            alldebrid.AllDebrid().user_transfers_to_listItem()
        elif action == 'ad_CloudStorage':
            from resources.lib.debrid import alldebrid
            alldebrid.AllDebrid().user_cloud_to_listItem()
        elif action == 'ad_BrowseUserCloud':
            from resources.lib.debrid import alldebrid
            alldebrid.AllDebrid().browse_user_cloud(source)
        elif action == 'ad_DeleteTransfer':
            from resources.lib.debrid import alldebrid
            alldebrid.AllDebrid().delete_transfer(id, name, silent=False)
        elif action == 'ad_RestartTransfer':
            from resources.lib.debrid import alldebrid
            alldebrid.AllDebrid().restart_transfer(id, name, silent=False)

    ####################################################
    #---Anime
    ####################################################
    elif action and action.startswith('anime_'):
        if action == 'anime_Navigator':
            from resources.lib.menus import navigator
            navigator.Navigator().anime()
        elif action == 'anime_Movies':
            from resources.lib.menus import movies
            movies.Movies().get(url)
        elif action == 'anime_TVshows':
            from resources.lib.menus import tvshows
            tvshows.TVshows().get(url)

    ####################################################
    #---YouTube
    ####################################################
    elif action == 'youtube':
        from resources.lib.menus import youtube
        if id is None: youtube.yt_index().root(action)
        else: youtube.yt_index().get(action, id)

    elif action == 'sectionItem':
        pass  # Placeholder. This is a non-clickable menu item for notes, etc.

    ####################################################
    #---Download
    ####################################################
    elif action and action.startswith('download'):
        if action == 'downloadNavigator':
            from resources.lib.menus import navigator
            navigator.Navigator().downloads()
        elif action == 'download':
            caller = params.get('caller')
            image = params.get('image')
            if caller == 'sources':  # future, move to downloader module for pack support
                control.busy()
                try:
                    from json import loads as jsloads
                    from resources.lib.modules import sources
                    from resources.lib.modules import downloader
                    downloader.download(
                        name, image,
                        sources.Sources().sourcesResolve(jsloads(source)[0]),
                        title)
                except:
                    import traceback
                    traceback.print_exc()
            if caller == 'premiumize':
                control.busy()
                try:
                    from resources.lib.modules import downloader
                    from resources.lib.debrid import premiumize
                    downloader.download(
                        name, image,
                        premiumize.Premiumize().add_headers_to_url(
                            url.replace(' ', '%20')))
                except:
                    import traceback
                    traceback.print_exc()
            if caller == 'realdebrid':
                control.busy()
                try:
                    from resources.lib.modules import downloader
                    from resources.lib.debrid import realdebrid
                    if type == 'unrestrict':
                        downloader.download(
                            name, image,
                            realdebrid.RealDebrid().unrestrict_link(
                                url.replace(' ', '%20')))
                    else:
                        downloader.download(name, image,
                                            url.replace(' ', '%20'))
                except:
                    import traceback
                    traceback.print_exc()
            if caller == 'alldebrid':
                control.busy()
                try:
                    from resources.lib.modules import downloader
                    from resources.lib.debrid import alldebrid
                    downloader.download(
                        name, image,
                        alldebrid.AllDebrid().unrestrict_link(
                            url.replace(' ', '%20')))
                except:
                    import traceback
                    traceback.print_exc()

    ####################################################
    #---Tools
    ####################################################
    elif action and action.startswith('tools_'):
        if action == 'tools_ShowNews':
            from resources.lib.modules import newsinfo
            newsinfo.news()
        elif action == 'tools_ShowChangelog':
            from resources.lib.modules import changelog
            changelog.get()
        elif action == 'tools_ShowHelp':
            from resources.help import help
            help.get(name)
        elif action == 'tools_LanguageInvoker':
            from resources.lib.modules import language_invoker
            language_invoker.set_reuselanguageinvoker()
        elif action == 'tools_toolNavigator':
            from resources.lib.menus import navigator
            navigator.Navigator().tools()
        elif action == 'tools_traktToolsNavigator':
            from resources.lib.menus import navigator
            navigator.Navigator().traktTools()
        elif action == 'tools_searchNavigator':
            from resources.lib.menus import navigator
            navigator.Navigator().search()
        elif action == 'tools_viewsNavigator':
            from resources.lib.menus import navigator
            navigator.Navigator().views()
        elif action == 'tools_addView':
            from resources.lib.modules import views
            content = params.get('content')
            views.addView(content)
        elif action == 'tools_resetViewTypes':
            from resources.lib.modules import views
            views.clearViews()
        elif action == 'tools_cleanSettings':
            from resources.lib.modules import clean_settings
            clean_settings.clean_settings()
        elif action == 'tools_openMyAccount':
            from myaccounts import openMASettings
            from resources.lib.modules import my_accounts
            openMASettings(query)
            control.sleep(500)
            while control.condVisibility('Window.IsVisible(addonsettings)'
                                         ) or control.homeWindow.getProperty(
                                             'myaccounts.active') == 'true':
                control.sleep(500)
            control.sleep(100)
            my_accounts.syncMyAccounts()
            control.sleep(100)
            if params.get('opensettings') == 'true':
                control.openSettings(params.get('query2'),
                                     'plugin.video.venom')
        elif action == 'tools_syncMyAccount':
            from resources.lib.modules import my_accounts
            my_accounts.syncMyAccounts()
            if params.get('opensettings') == 'true':
                control.openSettings(query, 'plugin.video.venom')
        elif action == 'tools_traktAcctMyAccounts':
            control.execute(
                'RunScript(script.module.myaccounts, action=traktAcct)')
        elif action == 'tools_adAcctMyAccounts':
            control.execute(
                'RunScript(script.module.myaccounts, action=alldebridAcct)')
        elif action == 'tools_pmAcctMyAccounts':
            control.execute(
                'RunScript(script.module.myaccounts, action=premiumizeAcct)')
        elif action == 'tools_rdAcctMyAccounts':
            control.execute(
                'RunScript(script.module.myaccounts, action=realdebridAcct)')
        elif action == 'tools_openSettings':
            control.openSettings(query)
        elif action == 'tools_contextVenomSettings':
            control.openSettings('0.0', 'context.venom')
            control.trigger_widget_refresh()
        elif action == 'tools_fenomscrapersSettings':
            control.openSettings('0.0', 'script.module.fenomscrapers')
        elif action == 'tools_traktManager':
            from resources.lib.modules import trakt
            watched = (params.get('watched')
                       == 'True') if params.get('watched') else None
            unfinished = (params.get('unfinished')
                          == 'True') if params.get('unfinished') else False
            trakt.manager(name,
                          imdb,
                          tvdb,
                          season,
                          episode,
                          watched=watched,
                          unfinished=unfinished)
        elif action == 'tools_cachesyncMovies':
            from resources.lib.modules import trakt
            trakt.cachesyncMovies(int(params.get('timeout')))
        elif action == 'tools_cachesyncTVShows':
            from resources.lib.modules import trakt
            trakt.cachesyncTVShows(int(params.get('timeout')))
        elif action == 'tools_syncTraktProgress':
            from resources.lib.modules import trakt
            trakt.sync_progress()
        elif action == 'tools_syncTraktWatched':
            from resources.lib.modules import trakt
            trakt.sync_watched()

    ####################################################
    #---Play
    ####################################################
    elif action and action.startswith('play_'):
        if action == 'play_Item':
            from resources.lib.modules import sources
            premiered = params.get('premiered')
            meta = params.get('meta')
            select = params.get('select')
            rescrape = params.get('rescrape')
            sources.Sources().play(title, year, imdb, tmdb, tvdb, season,
                                   episode, tvshowtitle, premiered, meta,
                                   select, rescrape)

            # if episode and control.homeWindow.getProperty('venom.isplaying.playlist') != 'true':
            # if int(episode) != 1: control.playlist.clear()
            # import xbmc
            # enable_playnext = control.setting('enable.playnext') == 'true'
            # media_type = 'movie' if tvshowtitle is None else 'episode'
            # rescrape = params.get('rescrape')
            # select = params.get('select')
            # if control.homeWindow.getProperty('venom.isplaying.playlist') == 'true' or enable_playnext is False or media_type == 'movie' or rescrape or select == '0':
            # try:
            # if control.homeWindow.getProperty('venom.isplaying.playlist') == 'true':
            # xbmc.log('[ plugin.video.venom ] venom.isplaying.playlist = %s' % control.homeWindow.getProperty('venom.isplaying.playlist'), 1)
            # from resources.lib.modules import sources
            # premiered = params.get('premiered')
            # meta = params.get('meta')
            # xbmc.log('[ plugin.video.venom ] control.playlist.size() = %s' % control.playlist.size(), 1)
            # xbmc.log('[ plugin.video.venom ] control.playlist.getposition() = %s' % control.playlist.getposition(), 1)
            # xbmc.log('[ plugin.video.venom ] Calling....sources.Sources().play()', 1)
            # if int(control.playlist.getposition()) == -1 or (int(control.playlist.getposition()) == (control.playlist.size() - 1)):
            # control.homeWindow.clearProperty('venom.isplaying.playlist')
            # sources.Sources().play(title, year, imdb, tmdb, tvdb, season, episode, tvshowtitle, premiered, meta, select, rescrape)
            # except:
            # import traceback
            # traceback.print_exc()
            # else:
            # try:
            # xbmc.log('[ plugin.video.venom ] control.playlist.size() = %s' % control.playlist.size(), 1)
            # is_widget = 'plugin' not in control.infoLabel('Container.PluginName')
            # if is_widget:
            # control.playlist.clear()
            # control.cancelPlayback()

            # # control.playlist.clear()
            # # control.cancelPlayback()

            # if control.playlist.size() <= 1:
            # current_ep = episode
            # xbmc.log('[ plugin.video.venom ] current_ep = %s' % current_ep, 1)
            # from json import dumps as jsdumps
            # from resources.lib.menus import episodes
            # meta = params.get('meta')
            # items = episodes.Episodes().get(tvshowtitle, year, imdb, tmdb, tvdb, meta, season, episode, create_directory=False)
            # control.playlist.clear()
            # for i in items:
            # title = i['title']
            # systitle = quote_plus(title)
            # year = i['year']
            # imdb = i['imdb']
            # tmdb = i['tmdb']
            # tvdb = i['tvdb']
            # season = i['season']
            # episode = i['episode']
            # tvshowtitle = i['tvshowtitle']
            # systvshowtitle = quote_plus(tvshowtitle)
            # premiered = i['premiered']
            # sysmeta = quote_plus(jsdumps(i))
            # url = 'plugin://plugin.video.venom/?action=play_Item&title=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&season=%s&episode=%s&tvshowtitle=%s&premiered=%s&meta=%s&select=1' % (
            # systitle, year, imdb, tmdb, tvdb, season, episode, systvshowtitle, premiered, sysmeta)
            # item = control.item(label=title, offscreen=True)
            # # item.setProperty('IsPlayable', 'true')
            # control.playlist.add(url=url, listitem=item)
            # control.homeWindow.setProperty('venom.isplaying.playlist', 'true')
            # playlist_urls = [control.playlist[i].getPath() for i in range(control.playlist.size())]
            # xbmc.log('[ plugin.video.venom ] control.playlist.size() = %s' % control.playlist.size(), 1)
            # xbmc.log('[ plugin.video.venom ] playlist_urls = %s' % playlist_urls, 1)
            # xbmc.log('[ plugin.video.venom ] Calling....control.player2().play(control.playlist)', 1)
            # control.player2().play(control.playlist)
            # return
            # except:
            # control.homeWindow.clearProperty('venom.isplaying.playlist')
            # import traceback
            # traceback.print_exc()

        elif action == "play_preScrapeNext":
            from resources.lib.modules.player import PlayNext
            PlayNext().prescrapeNext()

        elif action == "play_nextWindowXML":
            from resources.lib.modules.player import PlayNext
            play_next = PlayNext()
            play_next.display_xml()
            del play_next

        elif action == 'play_All':  # context menu works same as "Play from Here"
            control.player2().play(control.playlist)

        elif action == 'play_URL':
            caller = params.get('caller')
            if caller == 'realdebrid':
                from resources.lib.debrid import realdebrid
                if type == 'unrestrict':
                    control.player.play(
                        realdebrid.RealDebrid().unrestrict_link(
                            url.replace(' ', '%20')))
                else:
                    control.player.play(url.replace(' ', '%20'))
            elif caller == 'alldebrid':
                from resources.lib.debrid import alldebrid
                if type == 'unrestrict':
                    control.player.play(alldebrid.AllDebrid().unrestrict_link(
                        url.replace(' ', '%20')))
                else:
                    control.player.play(url.replace(' ', '%20'))
            else:
                control.player.play(url.replace(' ', '%20'))

        elif action == 'play_EpisodesList':  # global context option
            from json import dumps as jsdumps
            from resources.lib.menus import episodes
            meta = params.get('meta')
            items = episodes.Episodes().get(tvshowtitle,
                                            year,
                                            imdb,
                                            tmdb,
                                            tvdb,
                                            meta,
                                            season,
                                            episode,
                                            create_directory=False)
            control.playlist.clear()
            for i in items:
                title = i['title']
                systitle = quote_plus(title)
                year = i['year']
                imdb = i['imdb']
                tmdb = i['tmdb']
                tvdb = i['tvdb']
                season = i['season']
                episode = i['episode']
                tvshowtitle = i['tvshowtitle']
                systvshowtitle = quote_plus(tvshowtitle)
                premiered = i['premiered']
                sysmeta = quote_plus(jsdumps(i))
                url = 'plugin://plugin.video.venom/?action=play_Item&title=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&season=%s&episode=%s&tvshowtitle=%s&premiered=%s&meta=%s&select=1' % (
                    systitle, year, imdb, tmdb, tvdb, season, episode,
                    systvshowtitle, premiered, sysmeta)
                item = control.item(label=title, offscreen=True)
                control.playlist.add(url=url, listitem=item)
            control.player2().play(control.playlist)

        elif action == 'play_Trailer':
            from resources.lib.modules import trailer
            windowedtrailer = params.get('windowedtrailer')
            windowedtrailer = int(windowedtrailer) if windowedtrailer in (
                "0", "1") else 0
            trailer.Trailer().play(type, name, year, url, imdb,
                                   windowedtrailer)

        elif action == 'play_Random':
            rtype = params.get('rtype')
            if rtype == 'movie':
                from resources.lib.menus import movies
                rlist = movies.Movies().get(url, create_directory=False)
                xbmc.log('movie rlist=%s' % rlist, 1)
                xbmc.log('url=%s' % url, 1)
                r = 'plugin://plugin.video.venom/?action=play_Item'
            elif rtype == 'episode':
                from resources.lib.menus import episodes
                meta = params.get('meta')
                rlist = episodes.Episodes().get(tvshowtitle,
                                                year,
                                                imdb,
                                                tmdb,
                                                tvdb,
                                                meta,
                                                season,
                                                create_directory=False)
                r = 'plugin://plugin.video.venom/?action=play_Item'
            elif rtype == 'season':
                from resources.lib.menus import seasons
                art = params.get('art')
                rlist = seasons.Seasons().get(tvshowtitle,
                                              year,
                                              imdb,
                                              tmdb,
                                              tvdb,
                                              art,
                                              create_directory=False)
                r = 'plugin://plugin.video.venom/?action=play_Random&rtype=episode'
            elif rtype == 'show':
                from resources.lib.menus import tvshows
                rlist = tvshows.TVshows().get(url, create_directory=False)
                r = 'plugin://plugin.video.venom/?action=play_Random&rtype=season'
            from random import randint
            from json import dumps as jsdumps
            try:
                rand = randint(1, len(rlist)) - 1
                for p in [
                        'title', 'year', 'imdb', 'tmdb', 'tvdb', 'season',
                        'episode', 'tvshowtitle', 'premiered', 'select'
                ]:
                    if rtype == "show" and p == "tvshowtitle":
                        try:
                            r += '&' + p + '=' + quote_plus(
                                rlist[rand]['title'])
                        except:
                            pass
                    else:
                        try:
                            r += '&' + p + '=' + quote_plus(str(
                                rlist[rand][p]))
                        except:
                            pass
                try:
                    r += '&meta=' + quote_plus(jsdumps(rlist[rand]))
                except:
                    r += '&meta=' + quote_plus("{}")
                if rtype == "movie":
                    try:
                        control.notification(
                            title=32536,
                            message='%s (%s)' %
                            (rlist[rand]['title'], rlist[rand]['year']))
                    except:
                        pass
                elif rtype == "episode":
                    try:
                        control.notification(title=32536,
                                             message='%s - %01dx%02d - %s' %
                                             (rlist[rand]['tvshowtitle'],
                                              int(rlist[rand]['season']),
                                              int(rlist[rand]['episode']),
                                              rlist[rand]['title']))
                    except:
                        pass
                control.execute('RunPlugin(%s)' % r)
            except:
                control.notification(message=32537)

    elif action == 'play':  # for support of old style .strm library files
        from resources.lib.modules import sources
        premiered = params.get('premiered')
        meta = params.get('meta')
        select = params.get('select')
        rescrape = params.get('rescrape')
        sources.Sources().play(title, year, imdb, tmdb, tvdb, season, episode,
                               tvshowtitle, premiered, meta, select, rescrape)

    ####################################################
    #---Playlist
    ####################################################
    elif action and action.startswith('playlist_'):
        if action == 'playlist_Manager':
            from resources.lib.modules import playlist
            art = params.get('art')
            meta = params.get('meta')
            playlist.playlistManager(name, url, meta, art)
        elif action == 'playlist_Show':
            from resources.lib.modules import playlist
            playlist.playlistShow()
        elif action == 'playlist_Clear':
            from resources.lib.modules import playlist
            playlist.playlistClear()
        elif action == 'playlist_QueueItem':
            control.queueItem()
            if name is None: control.notification(title=35515, message=35519)
            else: control.notification(title=name, message=35519)

    ####################################################
    #---Playcount
    ####################################################
    elif action and action.startswith('playcount_'):
        if action == 'playcount_Movie':
            from resources.lib.modules import playcount
            playcount.movies(name, imdb, query)
        elif action == 'playcount_Episode':
            from resources.lib.modules import playcount
            playcount.episodes(name, imdb, tvdb, season, episode, query)
        elif action == 'playcount_TVShow':
            from resources.lib.modules import playcount
            playcount.tvshows(name, imdb, tvdb, season, query)

    ####################################################
    #---Source Actions
    ####################################################
    elif action == 'alterSources':
        from resources.lib.modules import sources
        meta = params.get('meta')
        sources.Sources().alterSources(url, meta)

    elif action == 'showDebridPack':
        from resources.lib.modules.sources import Sources
        caller = params.get('caller')
        Sources().debridPackDialog(caller, name, url, source)

    elif action == 'sourceInfo':
        from resources.lib.modules.sources import Sources
        Sources().sourceInfo(source)

    elif action == 'cacheTorrent':
        caller = params.get('caller')
        pack = True if type == 'pack' else False
        if caller == 'RD':
            from resources.lib.debrid.realdebrid import RealDebrid as debrid_function
        elif caller == 'PM':
            from resources.lib.debrid.premiumize import Premiumize as debrid_function
        elif caller == 'AD':
            from resources.lib.debrid.alldebrid import AllDebrid as debrid_function
        success = debrid_function().add_uncached_torrent(url, pack=pack)
        if success:
            from resources.lib.modules import sources
            meta = params.get('meta')
            items = params.get('items')
            sources.Sources().playItem(title, items, source, meta)

    ####################################################
    #---Library Actions
    ####################################################
    elif action and action.startswith('library_'):
        if action == 'library_Navigator':
            from resources.lib.menus import navigator
            navigator.Navigator().library()
        elif action == 'library_movieToLibrary':
            from resources.lib.modules import library
            library.libmovies().add(name, title, year, imdb, tmdb)
        elif action == 'library_moviesToLibrary':
            from resources.lib.modules import library
            library.libmovies().range(url, name)
        elif action == 'library_moviesListToLibrary':
            from resources.lib.menus import movies
            movies.Movies().moviesListToLibrary(url)
        elif action == 'library_moviesToLibrarySilent':
            from resources.lib.modules import library
            library.libmovies().silent(url)
        elif action == 'library_tvshowToLibrary':
            from resources.lib.modules import library
            library.libtvshows().add(tvshowtitle, year, imdb, tmdb, tvdb)
        elif action == 'library_tvshowsToLibrary':
            from resources.lib.modules import library
            library.libtvshows().range(url, name)
        elif action == 'library_tvshowsListToLibrary':
            from resources.lib.menus import tvshows
            tvshows.TVshows().tvshowsListToLibrary(url)
        elif action == 'library_tvshowsToLibrarySilent':
            from resources.lib.modules import library
            library.libtvshows().silent(url)
        elif action == 'library_update':
            control.notification(message=32085)
            from resources.lib.modules import library
            library.libepisodes().update()
            library.libmovies().list_update()
            library.libtvshows().list_update()
            while True:
                if control.condVisibility('Library.IsScanningVideo'):
                    control.sleep(3000)
                    continue
                else:
                    break
            control.sleep(1000)
            control.notification(message=32086)
        elif action == 'library_clean':
            from resources.lib.modules import library
            library.lib_tools().clean()
        elif action == 'library_setup':
            from resources.lib.modules import library
            library.lib_tools().total_setup()
        elif action == 'library_service':
            from resources.lib.modules import library
            library.lib_tools().service()

    ####################################################
    #---Cache
    ####################################################
    elif action and action.startswith('cache_'):
        if action == 'cache_Navigator':
            from resources.lib.menus import navigator
            navigator.Navigator().cf()
        elif action == 'cache_clearAll':
            from resources.lib.menus import navigator
            navigator.Navigator().clearCacheAll()
        elif action == 'cache_clearSources':
            from resources.lib.menus import navigator
            navigator.Navigator().clearCacheProviders()
        elif action == 'cache_clearMeta':
            from resources.lib.menus import navigator
            navigator.Navigator().clearCacheMeta()
        elif action == 'cache_clearCache':
            from resources.lib.menus import navigator
            navigator.Navigator().clearCache()
        elif action == 'cache_clearSearch':
            from resources.lib.menus import navigator
            navigator.Navigator().clearCacheSearch()
        elif action == 'cache_clearSearchPhrase':
            from resources.lib.menus import navigator
            navigator.Navigator().clearCacheSearchPhrase(source, name)
        elif action == 'cache_clearBookmarks':
            from resources.lib.menus import navigator
            navigator.Navigator().clearBookmarks()
        elif action == 'cache_clearBookmark':
            from resources.lib.menus import navigator
            navigator.Navigator().clearBookmark(name, year)
        elif action == 'cache_clearKodiBookmark':  # context.venom action call only
            from resources.lib.database import cache
            cache.clear_local_bookmark(url)
Exemplo n.º 24
0
def manager(name,
            imdb=None,
            tvdb=None,
            season=None,
            episode=None,
            refresh=True):
    lists = []
    try:
        if season: season = int(season)
        if episode: episode = int(episode)
        if tvdb: media_type = 'Show'
        else: media_type = 'Movie'

        items = [(control.lang(33651), 'watch')]
        items += [(control.lang(33652), 'unwatch')]
        items += [(control.lang(33653), 'rate')]
        items += [(control.lang(33654), 'unrate')]
        items += [(control.lang(40075) % media_type, 'hideItem')]
        if control.setting('trakt.scrobble') == 'true' and control.setting(
                'resume.source') == '1':
            items += [(control.lang(40076), 'scrobbleReset')]
        items += [(control.lang(33575), '/sync/collection')]
        items += [(control.lang(33576), '/sync/collection/remove')]
        if season or episode:
            items += [(control.lang(33573), '/sync/watchlist')]
            items += [(control.lang(33574), '/sync/watchlist/remove')]
        items += [(control.lang(33577), '/sync/watchlist')]
        items += [(control.lang(33578), '/sync/watchlist/remove')]
        items += [(control.lang(33579), '/users/me/lists/%s/items')]

        result = getTraktAsJson('/users/me/lists')
        lists = [(i['name'], i['ids']['slug']) for i in result]
        lists = [lists[i // 2] for i in range(len(lists) * 2)]

        for i in range(0, len(lists), 2):
            # lists[i] = ((control.lang(33580) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items' % lists[i][1])
            lists[i] = ((control.lang(33580) % lists[i][0]),
                        '/users/me/lists/%s/items' % lists[i][1])
        for i in range(1, len(lists), 2):
            # lists[i] = ((control.lang(33581) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items/remove' % lists[i][1])
            lists[i] = ((control.lang(33581) % lists[i][0]),
                        '/users/me/lists/%s/items/remove' % lists[i][1])
        items += lists

        control.hide()
        select = control.selectDialog([i[0] for i in items],
                                      heading=control.addonInfo('name') +
                                      ' - ' + control.lang(32515))

        if select == -1: return
        if select >= 0:
            if items[select][0] == control.lang(33651):
                control.busy()
                watch(name,
                      imdb=imdb,
                      tvdb=tvdb,
                      season=season,
                      episode=episode,
                      refresh=refresh)
                control.hide()
            elif items[select][0] == control.lang(33652):
                control.busy()
                unwatch(name,
                        imdb=imdb,
                        tvdb=tvdb,
                        season=season,
                        episode=episode,
                        refresh=refresh)
                control.hide()
            elif items[select][0] == control.lang(33653):
                control.busy()
                rate(imdb=imdb, tvdb=tvdb, season=season, episode=episode)
                control.hide()
            elif items[select][0] == control.lang(33654):
                control.busy()
                unrate(imdb=imdb, tvdb=tvdb, season=season, episode=episode)
                control.hide()
            elif items[select][0] == control.lang(40075) % media_type:
                control.busy()
                hideItem(name=name,
                         imdb=imdb,
                         tvdb=tvdb,
                         season=season,
                         episode=episode)
                control.hide()
            elif items[select][0] == control.lang(40076):
                control.busy()
                scrobbleReset(imdb=imdb,
                              tvdb=tvdb,
                              season=season,
                              episode=episode)
                control.hide()
            else:
                if not tvdb:
                    post = {"movies": [{"ids": {"imdb": imdb}}]}
                else:
                    if episode:
                        if items[select][0] == control.lang(33573) or items[
                                select][0] == control.lang(33574):
                            post = {"shows": [{"ids": {"tvdb": tvdb}}]}
                        else:
                            post = {
                                "shows": [{
                                    "ids": {
                                        "tvdb": tvdb
                                    },
                                    "seasons": [{
                                        "number":
                                        season,
                                        "episodes": [{
                                            "number": episode
                                        }]
                                    }]
                                }]
                            }
                            name = name + ' - ' + '%sx%02d' % (season, episode)
                    elif season:
                        if items[select][0] == control.lang(33573) or items[
                                select][0] == control.lang(33574):
                            post = {"shows": [{"ids": {"tvdb": tvdb}}]}
                        else:
                            post = {
                                "shows": [{
                                    "ids": {
                                        "tvdb": tvdb
                                    },
                                    "seasons": [{
                                        "number": season
                                    }]
                                }]
                            }
                            name = name + ' - ' + 'Season %s' % season
                    else:
                        post = {"shows": [{"ids": {"tvdb": tvdb}}]}

                if items[select][0] == control.lang(33579):
                    slug = listAdd(successNotification=True)
                    if slug:
                        getTrakt(items[select][1] % slug, post=post)[0]
                else:
                    getTrakt(items[select][1], post=post)[0]

                control.hide()
                message = 33583 if 'remove' in items[select][1] else 33582
                if refresh:
                    control.refresh()
                control.trigger_widget_refresh()
                if control.setting('trakt.general.notifications') == 'true':
                    control.notification(title=name, message=message)
    except:
        log_utils.error()
        control.hide()
Exemplo n.º 25
0
    def add_uncached_torrent(self, magnet_url, pack=False):
        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

        control.busy()
        try:
            active_count = self.torrents_activeCount()
            if active_count['nb'] >= active_count['limit']:
                return _return_failed()
        except:
            pass
        interval = 5
        stalled = ['magnet_error', 'error', 'virus', 'dead']
        extensions = supported_video_extensions()
        torrent = self.add_magnet(magnet_url)
        # if not transfer_id: # check if this is needed
        # control.hide()
        # return
        torrent_id = torrent['id']
        if not torrent_id:
            return _return_failed()
        torrent_info = self.torrent_info(torrent_id)
        if 'error_code' in torrent_info:
            # log_utils.log('torrent_info = %s' % torrent_info, __name__, log_utils.LOGDEBUG)
            return _return_failed()
        status = torrent_info['status']
        if status == 'magnet_conversion':
            line1 = control.lang(40013)
            line2 = torrent_info['filename']
            line3 = control.lang(40012) % str(torrent_info['seeders'])
            timeout = 100
            control.progressDialog.create(control.lang(40018), line1, line2,
                                          line3)
            while status == 'magnet_conversion' and timeout > 0:
                control.progressDialog.update(timeout, line3=line3)
                if control.monitor.abortRequested():
                    return sys.exit()
                try:
                    if control.progressDialog.iscanceled():
                        return _return_failed(control.lang(40014))
                except:
                    pass
                if any(x in status for x in stalled):
                    return _return_failed()
                timeout -= interval
                control.sleep(1000 * interval)
                torrent_info = self.torrent_info(torrent_id)
                status = torrent_info['status']
                line3 = control.lang(40012) % str(torrent_info['seeders'])
            try:
                control.progressDialog.close()
            except:
                pass
        if status == 'magnet_conversion':
            return _return_failed()
        if status == 'waiting_files_selection':
            video_files = []
            all_files = torrent_info['files']
            for item in all_files:
                if any(item['path'].lower().endswith(x) for x in extensions):
                    video_files.append(item)
            if pack:
                try:
                    if len(video_files) == 0:
                        return _return_failed()
                    video_files = sorted(video_files, key=lambda x: x['path'])
                    torrent_keys = [str(i['id']) for i in video_files]
                    if not torrent_keys:
                        return _return_failed(control.lang(40014))
                    torrent_keys = ','.join(torrent_keys)
                    self.select_file(torrent_id, torrent_keys)
                    control.okDialog(title='default',
                                     message=control.lang(40017) %
                                     control.lang(40058))
                    # self.clear_cache()
                    control.hide()
                    return True
                except:
                    return _return_failed()
            else:
                try:
                    video = max(video_files, key=lambda x: x['bytes'])
                    file_id = video['id']
                except ValueError:
                    return _return_failed()
                self.select_file(torrent_id, str(file_id))
            control.sleep(2000)
            torrent_info = self.torrent_info(torrent_id)
            status = torrent_info['status']
            if status == 'downloaded':
                return True
            file_size = round(float(video['bytes']) / (1000**3), 2)
            line1 = '%s...' % (control.lang(40017) % control.lang(40058))
            line2 = torrent_info['filename']
            line3 = status
            control.progressDialog.create(ls(40018), line1, line2, line3)
            while not status == 'downloaded':
                control.sleep(1000 * interval)
                torrent_info = self.torrent_info(torrent_id)
                status = torrent_info['status']
                if status == 'downloading':
                    line3 = control.lang(40011) % (
                        file_size,
                        round(float(torrent_info['speed']) / (1000**2), 2),
                        torrent_info['seeders'], torrent_info['progress'])
                else:
                    line3 = status
                control.progressDialog.update(int(
                    float(torrent_info['progress'])),
                                              line3=line3)
                if control.monitor.abortRequested():
                    return sys.exit()
                try:
                    if control.progressDialog.iscanceled():
                        return _return_failed(control.lang(40011))
                except:
                    pass
                if any(x in status for x in stalled):
                    return _return_failed()
            try:
                control.progressDialog.close()
            except Exception:
                pass
            control.hide()
            return True
        control.hide()
        return False
Exemplo n.º 26
0
    control.openSettings('0.0', 'script.module.orion')

elif action == 'download':
    import json
    from resources.lib.modules import sources
    from resources.lib.modules import downloader
    try:
        downloader.download(
            name, image,
            sources.sources().sourcesResolve(json.loads(source)[0], True))
    except:
        pass

elif action == 'play':
    from resources.lib.modules import control
    control.busy()
    from resources.lib.modules import sources
    sources.sources().play(title, year, imdb, tvdb, season, episode,
                           tvshowtitle, premiered, meta, select)
    control.idle()

elif action == 'addItem':
    from resources.lib.modules import sources
    sources.sources().addItem(title)

elif action == 'playItem':
    from resources.lib.modules import sources
    sources.sources().playItem(title, source)

elif action == 'alterSources':
    from resources.lib.modules import sources
Exemplo n.º 27
0
def manager(name,
            imdb=None,
            tvdb=None,
            season=None,
            episode=None,
            refresh=True):
    lists = []
    try:
        if season is not None:
            season = int(season)
        if episode is not None:
            episode = int(episode)

        items = [(control.lang(33651).encode('utf-8'), 'watch')]
        items += [(control.lang(33652).encode('utf-8'), 'unwatch')]
        items += [(control.lang(33653).encode('utf-8'), 'rate')]
        items += [(control.lang(33654).encode('utf-8'), 'unrate')]
        items += [(control.lang(33575).encode('utf-8'), '/sync/collection')]
        items += [(control.lang(33576).encode('utf-8'),
                   '/sync/collection/remove')]
        items += [(control.lang(33577).encode('utf-8'), '/sync/watchlist')]
        items += [(control.lang(33578).encode('utf-8'),
                   '/sync/watchlist/remove')]
        items += [(control.lang(33579).encode('utf-8'),
                   '/users/me/lists/%s/items')]

        result = getTraktAsJson('/users/me/lists')
        lists = [(i['name'], i['ids']['slug']) for i in result]
        lists = [lists[i // 2] for i in range(len(lists) * 2)]

        for i in range(0, len(lists), 2):
            lists[i] = ((control.lang(33580) % lists[i][0]).encode('utf-8'),
                        '/users/me/lists/%s/items' % lists[i][1])

        for i in range(1, len(lists), 2):
            lists[i] = ((control.lang(33581) % lists[i][0]).encode('utf-8'),
                        '/users/me/lists/%s/items/remove' % lists[i][1])
        items += lists

        control.hide()
        select = control.selectDialog([i[0] for i in items],
                                      heading=control.addonInfo('name') +
                                      ' - ' +
                                      control.lang(32515).encode('utf-8'))

        if select == -1:
            return
        if select >= 0:
            if select == 0:
                control.busy()
                watch(imdb=imdb,
                      tvdb=tvdb,
                      season=season,
                      episode=episode,
                      refresh=refresh,
                      notification=False)
                control.hide()
            elif select == 1:
                control.busy()
                unwatch(imdb=imdb,
                        tvdb=tvdb,
                        season=season,
                        episode=episode,
                        refresh=refresh,
                        notification=False)
                control.hide()
            elif select == 2:
                control.busy()
                rate(imdb=imdb, tvdb=tvdb, season=season, episode=episode)
                control.hide()
            elif select == 3:
                control.busy()
                unrate(imdb=imdb, tvdb=tvdb, season=season, episode=episode)
                control.hide()
            else:
                if tvdb is None:
                    post = {"movies": [{"ids": {"imdb": imdb}}]}
                else:
                    if episode is not None:
                        post = {
                            "shows": [{
                                "ids": {
                                    "tvdb": tvdb
                                },
                                "seasons": [{
                                    "number": season,
                                    "episodes": [{
                                        "number": episode
                                    }]
                                }]
                            }]
                        }
                        name = name + ' - ' + '%sx%02d' % (season, episode)
                    elif season is not None:
                        post = {
                            "shows": [{
                                "ids": {
                                    "tvdb": tvdb
                                },
                                "seasons": [{
                                    "number": season
                                }]
                            }]
                        }
                        name = name + ' - ' + 'Season %s' % season
                    else:
                        post = {"shows": [{"ids": {"tvdb": tvdb}}]}

                if select == 8:
                    slug = listAdd(successNotification=True)
                    if slug is not None:
                        getTrakt(items[select][1] % slug, post=post)[0]
                else:
                    getTrakt(items[select][1], post=post)[0]

                control.hide()
                message = 33583 if (select % 2) != 0 else 33582
                if select >= 9:
                    message = 33583 if (select % 2) == 0 else 33582
                control.notification(title=name,
                                     message=message,
                                     icon='INFO',
                                     sound=notificationSound)
    except:
        import traceback
        traceback.print_exc()
        control.hide()
Exemplo n.º 28
0
	def add_uncached_torrent(self, magnet_url, pack=False):
		def _return_failed(message=getLS(33586)):
			try: control.progressDialog.close()
			except: pass
			self.delete_torrent(torrent_id)
			control.hide()
			control.sleep(500)
			control.okDialog(title=getLS(40018), message=message)
			return False
		control.busy()
		try:
			active_count = self.torrents_activeCount()
			if active_count['nb'] >= active_count['limit']: return _return_failed()
		except: pass
		interval = 5
		stalled = ['magnet_error', 'error', 'virus', 'dead']
		extensions = supported_video_extensions()
		torrent_id = self.add_magnet(magnet_url)
		if not torrent_id: return _return_failed()
		torrent_info = self.torrent_info(torrent_id)
		if 'error_code' in torrent_info: return _return_failed()
		status = torrent_info['status']
		line = '%s\n%s\n%s'
		if status == 'magnet_conversion':
			line1 = getLS(40013)
			line2 = torrent_info['filename']
			line3 = getLS(40012) % str(torrent_info['seeders'])
			timeout = 100
			control.progressDialog.create(getLS(40018), line % (line1, line2, line3))
			while status == 'magnet_conversion' and timeout > 0:
				control.progressDialog.update(timeout, line % (line1, line2, line3))
				if control.monitor.abortRequested(): return sysexit()
				try:
					if control.progressDialog.iscanceled(): return _return_failed(getLS(40014))
				except: pass
				timeout -= interval
				control.sleep(1000 * interval)
				torrent_info = self.torrent_info(torrent_id)
				status = torrent_info['status']
				if any(x in status for x in stalled): return _return_failed()
				line3 = getLS(40012) % str(torrent_info['seeders'])
			try: control.progressDialog.close()
			except: pass
		if status == 'downloaded':
			control.busy()
			return True
		if status == 'magnet_conversion': return _return_failed()
		if any(x in status for x in stalled): return _return_failed(status)
		if status == 'waiting_files_selection': 
			video_files = []
			append = video_files.append
			all_files = torrent_info['files']
			for item in all_files:
				if any(item['path'].lower().endswith(x) for x in extensions): append(item)
			if pack:
				try:
					if len(video_files) == 0: return _return_failed()
					video_files.sort(key=lambda x: x['path'])
					torrent_keys = [str(i['id']) for i in video_files]
					if not torrent_keys: return _return_failed(getLS(40014))
					torrent_keys = ','.join(torrent_keys)
					self.add_torrent_select(torrent_id, torrent_keys)
					control.okDialog(title='default', message=getLS(40017) % getLS(40058))
					control.hide()
					return True # returning true here causes "success" to be returned and resolve runs on  non valid link
				except: return _return_failed()
			else:
				try:
					video = max(video_files, key=lambda x: x['bytes'])
					file_id = video['id']
				except ValueError: return _return_failed()
				self.add_torrent_select(torrent_id, str(file_id))
			control.sleep(2000)
			torrent_info = self.torrent_info(torrent_id)
			status = torrent_info['status']
			if status == 'downloaded':
				control.hide()
				control.notification(message=getLS(32057), icon=rd_icon)
				return True
			file_size = round(float(video['bytes']) / (1000 ** 3), 2)
			line1 = '%s...' % (getLS(40017) % getLS(40058))
			line2 = torrent_info['filename']
			line3 = status
			control.progressDialog.create(getLS(40018), line % (line1, line2, line3))
			while not status == 'downloaded':
				control.sleep(1000 * interval)
				torrent_info = self.torrent_info(torrent_id)
				status = torrent_info['status']
				if status == 'downloading':
					line3 = getLS(40011) % (file_size, round(float(torrent_info['speed']) / (1000**2), 2), torrent_info['seeders'], torrent_info['progress'])
				else:
					line3 = status
				control.progressDialog.update(int(float(torrent_info['progress'])), line % (line1, line2, line3))
				if control.monitor.abortRequested(): return sysexit()
				try:
					if control.progressDialog.iscanceled():
						if control.yesnoDialog('Delete RD download also?', 'No will continue the download', 'but close dialog'):
							return _return_failed(getLS(40014))
						else:
							control.progressDialog.close()
							control.hide()
							return False
				except: pass
				if any(x in status for x in stalled): return _return_failed()
			try: control.progressDialog.close()
			except: pass
			control.hide()
			return True
		control.hide()
		return False
Exemplo n.º 29
0
    def play_source(self,
                    title,
                    year,
                    season,
                    episode,
                    imdb,
                    tmdb,
                    tvdb,
                    url,
                    meta,
                    select=None):
        try:
            if not url: raise Exception
            self.media_type = 'movie' if season is None or episode is None else 'episode'
            self.title = title
            self.year = str(year)
            if self.media_type == 'movie':
                self.name = '%s (%s)' % (title, self.year)
                self.season = None
                self.episode = None
            elif self.media_type == 'episode':
                self.name = '%s S%02dE%02d' % (title, int(season),
                                               int(episode))
                self.season = '%01d' % int(season)
                self.episode = '%01d' % int(episode)

            self.DBID = None
            self.imdb = imdb if imdb is not None else ''
            self.tmdb = tmdb if tmdb is not None else ''
            self.tvdb = tvdb if tvdb is not None else ''
            self.ids = {
                'imdb': self.imdb,
                'tmdb': self.tmdb,
                'tvdb': self.tvdb
            }

            ## - compare meta received to database and use largest(eventually switch to a request to fetch missing db meta for item)
            self.imdb_user = control.setting('imdb.user').replace('ur', '')
            self.tmdb_key = control.setting('tmdb.api.key')
            if not self.tmdb_key:
                self.tmdb_key = '3320855e65a9758297fec4f7c9717698'
            self.tvdb_key = control.setting('tvdb.api.key')
            if self.media_type == 'episode':
                self.user = str(self.imdb_user) + str(self.tvdb_key)
            else:
                self.user = str(self.tmdb_key)
            self.lang = control.apiLanguage()['tvdb']
            meta1 = meta
            meta2 = metacache.fetch([{
                'imdb': self.imdb,
                'tmdb': self.tmdb,
                'tvdb': self.tvdb
            }], self.lang, self.user)[0]
            if meta2 != self.ids:
                meta2 = dict((k, v) for k, v in control.iteritems(meta2)
                             if v is not None and v != '')
            if meta1 is not None:
                try:
                    if len(meta2) > len(meta1):
                        meta2.update(meta1)
                        meta = meta2
                    else:
                        meta = meta1
                except:
                    log_utils.error()
            else:
                meta = meta2 if meta2 != self.ids else meta1
            ##################
            self.meta = meta
            poster, thumb, season_poster, fanart, banner, clearart, clearlogo, discart, meta = self.getMeta(
                meta)
            runtime = meta.get('duration') if meta else 0
            self.offset = Bookmarks().get(name=self.name,
                                          imdb=imdb,
                                          tmdb=tmdb,
                                          tvdb=tvdb,
                                          season=season,
                                          episode=episode,
                                          year=self.year,
                                          runtime=runtime)
            item = control.item(path=url)
            item.setUniqueIDs(self.ids)
            if control.setting('disable.player.art') == 'true':
                for k in ('clearart', 'clearlogo', 'discart'):
                    meta.pop(k, None)
            if self.media_type == 'episode':
                if control.setting('disable.player.art') == 'true':
                    item.setArt({
                        'thumb': thumb,
                        'tvshow.poster': season_poster,
                        'season.poster': season_poster,
                        'tvshow.fanart': fanart
                    })
                else:
                    item.setArt({
                        'tvshow.clearart': clearart,
                        'tvshow.clearlogo': clearlogo,
                        'tvshow.discart': discart,
                        'thumb': thumb,
                        'tvshow.poster': season_poster,
                        'season.poster': season_poster,
                        'tvshow.fanart': fanart
                    })
            else:
                if control.setting('disable.player.art') == 'true':
                    item.setArt({
                        'thumb': thumb,
                        'poster': poster,
                        'fanart': fanart
                    })
                else:
                    item.setArt({
                        'clearart': clearart,
                        'clearlogo': clearlogo,
                        'discart': discart,
                        'thumb': thumb,
                        'poster': poster,
                        'fanart': fanart
                    })

            if 'castandart' in meta: item.setCast(meta.get('castandart', ''))
            item.setInfo(type='video', infoLabels=control.metadataClean(meta))
            if 'plugin' not in control.infoLabel(
                    'Container.PluginName') or select != '1':
                control.busy()
                control.resolve(int(argv[1]), True, item)
            elif select == '1':
                control.busy()
                control.player.play(url, item)
            control.homeWindow.setProperty('script.trakt.ids',
                                           jsdumps(self.ids))
            self.keepAlive()
            control.homeWindow.clearProperty('script.trakt.ids')
        except:
            log_utils.error()
            return control.cancelPlayback()
Exemplo n.º 30
0
def tvshows(tvshowtitle, imdb, tmdb, season, watched):
    control.busy()
    try:
        import sys, xbmc

        if not trakt.getTraktIndicatorsInfo() == False: raise Exception()

        from resources.lib.indexers import episodes

        name = control.addonInfo('name')

        dialog = control.progressDialogBG
        dialog.create(str(name), str(tvshowtitle))
        dialog.update(0, str(name), str(tvshowtitle))

        #log_utils.log('playcount_season: ' + str(season))
        items = []
        if season:
            items = episodes.episodes().get(tvshowtitle,
                                            '0',
                                            imdb,
                                            tmdb,
                                            meta=None,
                                            season=season,
                                            idx=False)
            items = [
                i for i in items
                if int('%01d' % int(season)) == int('%01d' % int(i['season']))
            ]
            items = [{
                'label':
                '%s S%02dE%02d' %
                (tvshowtitle, int(i['season']), int(i['episode'])),
                'season':
                int('%01d' % int(i['season'])),
                'episode':
                int('%01d' % int(i['episode'])),
                'unaired':
                i['unaired']
            } for i in items]

            for i in range(len(items)):
                if control.monitor.abortRequested(): return sys.exit()

                dialog.update(int((100 / float(len(items))) * i), str(name),
                              str(items[i]['label']))

                _season, _episode, unaired = items[i]['season'], items[i][
                    'episode'], items[i]['unaired']
                if int(watched) == 7:
                    if not unaired == 'true':
                        bookmarks.reset(1, 1, 'episode', imdb, _season,
                                        _episode)
                    else:
                        pass
                else:
                    bookmarks._delete_record('episode', imdb, _season,
                                             _episode)

        else:
            seasons = episodes.seasons().get(tvshowtitle,
                                             '0',
                                             imdb,
                                             tmdb,
                                             meta=None,
                                             idx=False)
            seasons = [i['season'] for i in seasons]
            #log_utils.log('playcount_seasons: ' + str(seasons))
            for s in seasons:
                items = episodes.episodes().get(tvshowtitle,
                                                '0',
                                                imdb,
                                                tmdb,
                                                meta=None,
                                                season=s,
                                                idx=False)
                items = [{
                    'label':
                    '%s S%02dE%02d' %
                    (tvshowtitle, int(i['season']), int(i['episode'])),
                    'season':
                    int('%01d' % int(i['season'])),
                    'episode':
                    int('%01d' % int(i['episode'])),
                    'unaired':
                    i['unaired']
                } for i in items]
                #log_utils.log('playcount_items2: ' + str(items))

                for i in range(len(items)):
                    if control.monitor.abortRequested(): return sys.exit()

                    dialog.update(int((100 / float(len(items))) * i),
                                  str(name), str(items[i]['label']))

                    _season, _episode, unaired = items[i]['season'], items[i][
                        'episode'], items[i]['unaired']
                    if int(watched) == 7:
                        if not unaired == 'true':
                            bookmarks.reset(1, 1, 'episode', imdb, _season,
                                            _episode)
                        else:
                            pass
                    else:
                        bookmarks._delete_record('episode', imdb, _season,
                                                 _episode)

        try:
            dialog.close()
        except:
            pass
    except:
        log_utils.log('playcount_local_shows', 1)
        try:
            dialog.close()
        except:
            pass

    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()

        #log_utils.log('playcount_season: ' + str(season))
        if season:
            from resources.lib.indexers import episodes
            items = episodes.episodes().get(tvshowtitle,
                                            '0',
                                            imdb,
                                            tmdb,
                                            meta=None,
                                            season=season,
                                            idx=False)
            items = [(int(i['season']), int(i['episode'])) for i in items]
            items = [
                i[1] for i in items
                if int('%01d' % int(season)) == int('%01d' % i[0])
            ]
            for i in items:
                if int(watched) == 7:
                    trakt.markEpisodeAsWatched(imdb, season, i)
                else:
                    trakt.markEpisodeAsNotWatched(imdb, season, i)
        else:
            if int(watched) == 7: trakt.markTVShowAsWatched(imdb)
            else: trakt.markTVShowAsNotWatched(imdb)
        trakt.cachesyncTVShows()
    except:
        log_utils.log('playcount_trakt_shows', 1)
        pass

    control.refresh()
    control.idle()