def auth(self):
        self.secret = ''
        self.client_ID = 'X245A4XAIBGVM'
        line = '%s[CR]%s[CR]%s'
        url = 'client_id=%s&new_credentials=yes' % self.client_ID
        url = auth_url + device_url % url
        response = json.loads(requests.get(url, timeout=self.timeout).text)
        progressDialog.create('%s %s' % (ls(32054), ls(32057)),
                              line % ('', '', ''))
        progressDialog.update(
            -1,
            line % (ls(32517), ls(32700) % 'https://real-debrid.com/device',
                    ls(32701) % response['user_code']))
        self.auth_timeout = int(response['expires_in'])
        self.auth_step = int(response['interval'])
        self.device_code = response['device_code']

        while self.secret == '':
            if self.break_auth_loop:
                break
            if progressDialog.iscanceled():
                progressDialog.close()
                break
            self.auth_loop()
        self.get_token()
Beispiel #2
0
 def make_context_menu(self):
     enable_delete = self.list_item.getProperty(
         'tikiskins.delete') == 'true'
     path = self.list_item.getProperty('tikiskins.path')
     thumb_url = self.list_item.getProperty('tikiskins.thumb')
     if enable_delete:
         folder_path = self.list_item.getProperty('tikiskins.folder_path')
         delete_file_params = {
             'mode': 'delete_image',
             'image_url': path,
             'thumb_url': thumb_url,
             'folder_path': folder_path,
             'in_progress': 'true'
         }
         self.item_list.append(
             self.make_contextmenu_item('[B]%s[/B]' % ls(32785),
                                        'RunPlugin(%s)',
                                        delete_file_params))
     else:
         name = self.list_item.getProperty('tikiskins.name')
         down_file_params = {
             'mode': 'downloader',
             'action': 'image',
             'name': name,
             'thumb_url': thumb_url,
             'image_url': path,
             'db_type': 'image',
             'image': icon
         }
         self.item_list.append(
             self.make_contextmenu_item(ls(32747), 'RunPlugin(%s)',
                                        down_file_params))
Beispiel #3
0
 def debrid_check_dialog(self):
     start_time = time.time()
     end_time = start_time + self.timeout
     line = '%s[CR]%s[CR]%s'
     plswait_str, checking_debrid, remaining_debrid = ls(32577), ls(
         32578), ls(32579)
     while not self.progress_dialog.iscanceled():
         try:
             if monitor.abortRequested() is True: break
             remaining_debrids = [
                 x.getName() for x in self.main_threads
                 if x.is_alive() is True
             ]
             current_time = time.time()
             current_progress = current_time - start_time
             try:
                 line3 = remaining_debrid % ', '.join(
                     remaining_debrids).upper()
                 percent = int(
                     (current_progress / float(self.timeout)) * 100)
                 self.progress_dialog.update(
                     line % (plswait_str, checking_debrid, line3), percent)
             except:
                 pass
             sleep(self.sleep_time)
             if len(remaining_debrids) == 0: break
             if current_time > end_time: break
         except Exception:
             pass
 def revoke_auth(self):
     set_setting('rd.auth', '')
     set_setting('rd.client_id', '')
     set_setting('rd.refresh', '')
     set_setting('rd.secret', '')
     set_setting('rd.token', '')
     set_setting('rd.username', '')
     ok_dialog(heading=32054, text='%s %s' % (ls(32059), ls(32576)))
Beispiel #5
0
	def clear_favourites(self):
		favorites = ls(32453)
		fl = [('%s %s' % (ls(32028), ls(32453)), 'movie'), ('%s %s' % (ls(32029), ls(32453)), 'tvshow')]
		list_items = [{'line1': item[0]} for item in fl]
		kwargs = {'items': json.dumps(list_items), 'heading': 'Fen', 'enumerate': 'false', 'multi_choice': 'false', 'multi_line': 'false'}
		self.db_type = select_dialog([item[1] for item in fl], **kwargs)
		if self.db_type == None: return
		if not confirm_dialog(): return
		dbcon = database.connect(self.fav_database)
		dbcon.execute("DELETE FROM favourites WHERE db_type=?", (self.db_type,))
		dbcon.commit()
		dbcon.execute('VACUUM')
		dbcon.close()
		notification(32576, 3000)
 def _return_failed(message=32574, cancelled=False):
     try:
         progressDialog.close()
     except Exception:
         pass
     hide_busy_dialog()
     sleep(500)
     if cancelled:
         if confirm_dialog(text=32044, top_space=True):
             ok_dialog(heading=32733, text=ls(32732) % ls(32054))
         else:
             self.delete_torrent(torrent_id)
     else:
         ok_dialog(heading=32733, text=message)
     return False
Beispiel #7
0
def batch_mark_episodes_as_watched_unwatched_kodi_library(
        action, show_info, episode_list):
    playcount = 1 if action == 'mark_as_watched' else 0
    tvshowid = str(show_info['tvshowid'])
    ep_ids = []
    action_list = []
    ep_ids_append = ep_ids.append
    action_append = action_list.append
    progressDialogBG.create(ls(32577), '')
    try:
        for item in episode_list:
            try:
                season = item[2]
                episode = item[3]
                r = execute_JSON(
                    '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"filter":{"and": [{"field": "season", "operator": "is", "value": "%s"}, {"field": "episode", "operator": "is", "value": "%s"}]}, "properties": ["file", "playcount"], "tvshowid": %s }, "id": 1}'
                    % (str(season), str(episode), str(tvshowid)))
                r = to_utf8(r)
                r = json.loads(r)['result']['episodes'][0]
                ep_ids_append((r['episodeid'], r['playcount']))
            except:
                pass
        for count, item in enumerate(ep_ids, 1):
            try:
                ep_id = item[0]
                current_playcount = item[1]
                if int(current_playcount) != playcount:
                    sleep(50)
                    display = ls(32856)
                    progressDialogBG.update(
                        int(float(count) / float(len(ep_ids)) * 100),
                        ls(32577), display)
                    t = '{"jsonrpc": "2.0", "method": "VideoLibrary.SetEpisodeDetails", "params": {"episodeid" : %d, "playcount" : %d }, "id": 1 }' % (
                        int(ep_id), playcount)
                    t = json.loads(t)
                    action_append(t)
                else:
                    pass
            except:
                pass
        progressDialogBG.update(100, ls(32577), ls(32788))
        r = execute_JSON(json.dumps(action_list))
        progressDialogBG.close()
        return r
    except:
        pass
Beispiel #8
0
 def make_next_page(self):
     try:
         listitem = self.make_listitem()
         listitem.setProperty('tikiskins.name', ls(32799))
         listitem.setProperty('tikiskins.thumb', next_icon)
         listitem.setProperty('tikiskins.next_page_item', 'true')
         self.list_items.append(listitem)
     except:
         pass
 def auth(self):
     self.token = ''
     line = '%s[CR]%s[CR]%s'
     data = {'response_type': 'device_code', 'client_id': self.client_id}
     url = 'https://www.premiumize.me/token'
     response = self._post(url, data)
     progressDialog.create('Fen', '')
     progressDialog.update(
         -1,
         line % (ls(32517), ls(32700) % response.get('verification_uri'),
                 ls(32701) % response.get('user_code')))
     self.device_code = response['device_code']
     while self.token == '':
         self.auth_loop()
     if self.token is None: return
     account_info = self.account_info()
     set_setting('pm.account_id', str(account_info['customer_id']))
     ok_dialog(text=32576, top_space=True)
Beispiel #10
0
 def make_person_data(self):
     if self.kwargs['query']:
         try:
             self.person_id = tmdb_people_info(
                 self.kwargs['query'])[0]['id']
         except:
             notification(32760)
     else:
         self.person_id = self.kwargs['actor_id']
     person_info = tmdb_people_full_info(self.person_id)
     if person_info.get('biography', None) in ('', None):
         person_info = tmdb_people_full_info(self.person_id, 'en')
     self.person_name = person_info['name']
     image_path = person_info['profile_path']
     if image_path:
         self.person_image = tmdb_image_base % ('h632', image_path)
     else:
         self.person_image = backup_cast_thumbnail
     gender = person_info.get('gender')
     if gender: self.person_gender = gender_dict[gender]
     else: self.person_gender = ''
     place_of_birth = person_info.get('place_of_birth')
     if place_of_birth: self.person_place_of_birth = place_of_birth
     else: self.person_place_of_birth = ''
     biography = person_info.get('biography')
     if biography: self.person_biography = biography
     else: self.person_biography = ls(32760)
     birthday = person_info.get('birthday')
     if birthday: self.person_birthday = birthday
     else: self.person_birthday = ''
     deathday = person_info.get('deathday')
     if deathday: self.person_deathday = deathday
     else: self.person_deathday = ''
     if self.person_deathday:
         self.person_age = calculate_age(self.person_birthday, '%Y-%m-%d',
                                         self.person_deathday)
     elif self.person_birthday:
         self.person_age = calculate_age(self.person_birthday, '%Y-%m-%d')
     else:
         self.person_age = ''
     self.imdb_id = person_info['imdb_id']
     more_from_data = person_info['combined_credits']
     acting_data = more_from_data['cast']
     directing_data = more_from_data['crew']
     self.movie_data = [
         i for i in acting_data if i['media_type'] == 'movie'
     ]
     self.tvshow_data = [i for i in acting_data if i['media_type'] == 'tv']
     self.director_data = [
         i for i in directing_data if i['job'].lower() == 'director'
     ]
 def auth_loop(self):
     sleep(1000 * self.auth_step)
     url = 'client_id=%s&code=%s' % (self.client_ID, self.device_code)
     url = auth_url + credentials_url % url
     response = json.loads(requests.get(url, timeout=self.timeout).text)
     if 'error' in response:
         return
     try:
         progressDialog.close()
         set_setting('rd.client_id', response['client_id'])
         set_setting('rd.secret', response['client_secret'])
         self.secret = response['client_secret']
         self.client_ID = response['client_id']
     except:
         ok_dialog(text=ls(32574), top_space=True)
         self.break_auth_loop = True
     return
Beispiel #12
0
    'real-debrid': translate_path(media_folder % 'providers/realdebrid.png'),
    'premiumize': translate_path(media_folder % 'providers/premiumize.png'),
    'ad_cloud': translate_path(media_folder % 'providers/alldebrid.png'),
    'rd_cloud': translate_path(media_folder % 'providers/realdebrid.png'),
    'pm_cloud': translate_path(media_folder % 'providers/premiumize.png')
}
info_quality_dict = {
    '4k': translate_path(media_folder % 'flags/4k.png'),
    '1080p': translate_path(media_folder % 'flags/1080p.png'),
    '720p': translate_path(media_folder % 'flags/720p.png'),
    'sd': translate_path(media_folder % 'flags/sd.png'),
    'cam': translate_path(media_folder % 'flags/sd.png'),
    'tele': translate_path(media_folder % 'flags/sd.png'),
    'scr': translate_path(media_folder % 'flags/sd.png')
}
filter_str, clr_filter_str, extra_info_str, down_file_str, browse_pack_str = ls(
    32152), ls(32153), ls(32605), ls(32747), ls(33004)
down_pack_str, furk_addto_str, cloud_str = ls(32007), ls(32769), ls(32016)
filters_ignored, start_full_scrape = ls(32686), ls(33023)
filter_quality, filter_provider, filter_title, filter_extraInfo = ls(
    32154), ls(32157), ls(32679), ls(32169)
run_plugin_str = 'RunPlugin(%s)'
backup_poster = translate_path(
    'special://home/addons/script.tikiart/resources/media/box_office.png')
backup_fanart = translate_path(
    'special://home/addons/plugin.video.fen/fanart.png')
string = str
upper = string.upper
lower = string.lower


class SourceResults(BaseDialog):
Beispiel #13
0
    def add_uncached_torrent(self, magnet_url, pack=False):
        from modules.kodi_utils import show_busy_dialog, hide_busy_dialog
        from modules.source_utils import supported_video_extensions

        def _transfer_info(transfer_id):
            info = self.transfers_list()
            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=32574, cancelled=False):
            try:
                progressDialog.close()
            except Exception:
                pass
            hide_busy_dialog()
            sleep(500)
            if cancelled:
                if confirm_dialog(heading=32733, text=32044, top_space=True):
                    ok_dialog(heading=32733, text=ls(32732) % ls(32061))
                else:
                    self.delete_transfer(transfer_id)
            else:
                ok_dialog(heading=32733, text=message)
            return False

        show_busy_dialog()
        extensions = supported_video_extensions()
        transfer_id = self.create_transfer(magnet_url)
        if not transfer_id['status'] == 'success':
            return _return_failed(transfer_id.get('message'))
        transfer_id = transfer_id['id']
        transfer_info = _transfer_info(transfer_id)
        if not transfer_info: return _return_failed()
        if pack:
            self.clear_cache()
            hide_busy_dialog()
            ok_dialog(text=ls(32732) % ls(32061))
            return True
        interval = 5
        line = '%s[CR]%s[CR]%s'
        line1 = '%s...' % (ls(32732) % ls(32061))
        line2 = transfer_info['name']
        line3 = transfer_info['message']
        progressDialog.create(ls(32733), line % (line1, line2, line3))
        while not transfer_info['status'] == 'seeding':
            sleep(1000 * interval)
            transfer_info = _transfer_info(transfer_id)
            line3 = transfer_info['message']
            progressDialog.update(int(float(transfer_info['progress']) * 100),
                                  line % (line1, line2, line3))
            if monitor.abortRequested() == True: return sysexit()
            try:
                if progressDialog.iscanceled():
                    return _return_failed(ls(32736), cancelled=True)
            except Exception:
                pass
            if transfer_info.get('status') == 'stalled':
                return _return_failed()
        sleep(1000 * interval)
        try:
            progressDialog.close()
        except Exception:
            pass
        hide_busy_dialog()
        return True
Beispiel #14
0
 def revoke_auth(self):
     set_setting('pm.account_id', '')
     set_setting('pm.token', '')
     ok_dialog(heading=32061, text='%s %s' % (ls(32059), ls(32576)))
Beispiel #15
0
from apis.imdb_api import imdb_videos
from indexers.images import Images
from indexers import dialogs
from modules.kodi_utils import translate_path, notification, show_text, local_string as ls
from modules.settings import extras_enable_scrollbars, extras_exclude_non_acting, get_resolution
from modules.utils import calculate_age
# from modules.kodi_utils import logger

tmdb_image_base = 'https://image.tmdb.org/t/p/%s%s'
fanart = translate_path('special://home/addons/plugin.video.fen/fanart.png')
backup_thumbnail = translate_path(
    'special://home/addons/script.tikiart/resources/media/box_office.png')
backup_cast_thumbnail = translate_path(
    'special://home/addons/script.tikiart/resources/media/genre_family.png')
button_ids = [10, 11, 50]
gender_dict = {1: ls(32844), 2: ls(32843)}
roles_exclude = ('himself', 'herself', 'self', 'narrator', 'voice (voice)')
genres_exclude = (10763, 10764, 10767)

more_from_movies_id = 2050
more_from_tvshows_id = 2051
imdb_videos_id = 2052
more_from_director_id = 2053


class People(BaseDialog):
    def __init__(self, *args, **kwargs):
        BaseDialog.__init__(self, args)
        self.control_id = None
        self.kwargs = kwargs
        self.set_starting_constants()
Beispiel #16
0
		'R',
		'NC-17',
		'NR'
	)

tvshow_certifications = (
		'tv-y',
		'tv-y7',
		'tv-g',
		'tv-pg',
		'tv-14',
		'tv-ma'
	)

languages = (
		(ls(32861), 'ar'), (ls(32862), 'bs'),   (ls(32863), 'bg'),   (ls(32864), 'zh'),   (ls(32865), 'hr'),   (ls(32866), 'nl'),   (ls(32867), 'en'),
		(ls(32868), 'fi'), (ls(32869), 'fr'),   (ls(32870), 'de'),   (ls(32871), 'el'),   (ls(32872), 'he'),   (ls(32873), 'hi'),   (ls(32874), 'hu'),
		(ls(32875), 'is'), (ls(32876), 'it'),   (ls(32877), 'ja'),   (ls(32878), 'ko'),   (ls(32879), 'mk'),   (ls(32880), 'no'),   (ls(32881), 'fa'),
		(ls(32882), 'pl'), (ls(32883), 'pt'),   (ls(32884), 'pa'),   (ls(32885), 'ro'),   (ls(32886), 'ru'),   (ls(32887), 'sr'),   (ls(32888), 'sl'),
		(ls(32889), 'es'), (ls(32890), 'sv'),   (ls(32891), 'tr'),   (ls(32892), 'uk')
	)
		

meta_languages = (
		{'iso': 'zh', 'name': 'Chinese'},     {'iso': 'hr', 'name': 'Croatian'},
		{'iso': 'cs', 'name': 'Czech'},       {'iso': 'da', 'name': 'Danish'},
		{'iso': 'nl', 'name': 'Dutch'},       {'iso': 'en', 'name': 'English'},
		{'iso': 'fi', 'name': 'Finnish'},     {'iso': 'fr', 'name': 'French'},
		{'iso': 'de', 'name': 'German'},      {'iso': 'el', 'name': 'Greek'},
		{'iso': 'he', 'name': 'Hebrew'},      {'iso': 'h', 'name': 'Hungarian'},
		{'iso': 'it', 'name': 'Italian'},     {'iso': 'ja', 'name': 'Japanese'},
    def add_uncached_torrent(self, magnet_url, pack=False):
        from modules.kodi_utils import show_busy_dialog, hide_busy_dialog
        from modules.source_utils import supported_video_extensions

        def _return_failed(message=32574, cancelled=False):
            try:
                progressDialog.close()
            except Exception:
                pass
            hide_busy_dialog()
            sleep(500)
            if cancelled:
                if confirm_dialog(text=32044, top_space=True):
                    ok_dialog(heading=32733, text=ls(32732) % ls(32054))
                else:
                    self.delete_torrent(torrent_id)
            else:
                ok_dialog(heading=32733, text=message)
            return False

        show_busy_dialog()
        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)
        torrent_id = torrent['id']
        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[CR]%s[CR]%s'
        if status == 'magnet_conversion':
            line1 = ls(32737)
            line2 = torrent_info['filename']
            line3 = ls(32738) % torrent_info['seeders']
            timeout = 100
            progressDialog.create(ls(32733), line % (line1, line2, line3))
            while status == 'magnet_conversion' and timeout > 0:
                progressDialog.update(timeout, line % (line1, line2, line3))
                if monitor.abortRequested() == True: return sysexit()
                try:
                    if progressDialog.iscanceled():
                        return _return_failed(32736, cancelled=True)
                except Exception:
                    pass
                timeout -= interval
                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 = ls(32738) % torrent_info['seeders']
            try:
                progressDialog.close()
            except Exception:
                pass
        if status == 'downloaded':
            hide_busy_dialog()
            return True
        if status == 'magnet_conversion':
            return _return_failed()
        if any(x in status for x in stalled):
            return _return_failed(str(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(ls(32736))
                    torrent_keys = ','.join(torrent_keys)
                    self.add_torrent_select(torrent_id, torrent_keys)
                    ok_dialog(text=ls(32732) % ls(32054))
                    self.clear_cache()
                    hide_busy_dialog()
                    return True
                except Exception:
                    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))
            sleep(2000)
            torrent_info = self.torrent_info(torrent_id)
            status = torrent_info['status']
            if status == 'downloaded':
                hide_busy_dialog()
                return True
            file_size = round(float(video['bytes']) / (1000**3), 2)
            line1 = '%s...' % (ls(32732) % ls(32054))
            line2 = torrent_info['filename']
            line3 = status
            progressDialog.create(ls(32733), line % (line1, line2, line3))
            while not status == 'downloaded':
                sleep(1000 * interval)
                torrent_info = self.torrent_info(torrent_id)
                status = torrent_info['status']
                if status == 'downloading':
                    line3 = ls(32739) % (
                        file_size,
                        round(float(torrent_info['speed']) / (1000**2), 2),
                        torrent_info['seeders'], torrent_info['progress'])
                else:
                    line3 = status
                progressDialog.update(int(float(torrent_info['progress'])),
                                      line % (line1, line2, line3))
                if monitor.abortRequested() == True: return sys.exit()
                try:
                    if progressDialog.iscanceled():
                        return _return_failed(32736, cancelled=True)
                except:
                    pass
                if any(x in status for x in stalled): return _return_failed()
            try:
                progressDialog.close()
            except:
                pass
            hide_busy_dialog()
            return True
        hide_busy_dialog()
        return False