Exemplo n.º 1
0
 def _add_defaults(self):
     if self.discover_params['db_type'] == 'movie':
         mode = 'build_movie_list'
         action = 'tmdb_movies_discover'
     else:
         mode = 'build_tvshow_list'
         action = 'tmdb_tv_discover'
     name = self.discover_params.get('name', '...')
     query = self.discover_params.get('final_string', '')
     self._add_dir(
         {
             'mode': mode,
             'action': action,
             'query': query,
             'name': name,
             'list_name': ls(32666) % name
         },
         isFolder=True,
         icon=kodi_utils.translate_path(icon_directory % 'search.png'))
     self._add_dir(
         {
             'mode': 'discover.export',
             'db_type': self.db_type,
             'list_name': ls(32667) % name
         },
         icon=kodi_utils.translate_path(icon_directory % 'nextpage.png'))
Exemplo n.º 2
0
def build_navigate_to_page(params):
    import json
    from modules.settings import nav_jump_use_alphabet
    use_alphabet = nav_jump_use_alphabet()
    icon = kodi_utils.translate_path(
        'special://home/addons/script.tikiart/resources/media/item_jump.png')
    fanart = kodi_utils.translate_path(
        'special://home/addons/plugin.video.fen/fanart.png')
    db_type = params.get('db_type')

    def _builder(use_alphabet):
        for i in start_list:
            if use_alphabet:
                line1, line2 = i.upper(), ls(32821) % (db_type, i.upper())
            else:
                line1, line2 = '%s %s' % (ls(32022), i), ls(32822) % i
            yield {'line1': line1, 'line2': line2, 'icon': icon}

    if use_alphabet:
        start_list = [chr(i) for i in range(97, 123)]
    else:
        start_list = [
            str(i) for i in range(1,
                                  int(params.get('total_pages')) + 1)
        ]
        start_list.remove(params.get('current_page'))
    list_items = list(_builder(use_alphabet))
    kwargs = {
        'items': json.dumps(list_items),
        'heading': 'Fen',
        'enumerate': 'false',
        'multi_choice': 'false',
        'multi_line': 'false'
    }
    new_start = kodi_utils.select_dialog(start_list, **kwargs)
    kodi_utils.sleep(100)
    if new_start == None: return
    if use_alphabet: new_page, new_letter = '', new_start
    else: new_page, new_letter = new_start, None
    url_params = {
        'mode': params.get('transfer_mode', ''),
        'action': params.get('transfer_action', ''),
        'new_page': new_page,
        'new_letter': new_letter,
        'media_type': params.get('media_type', ''),
        'query': params.get('query', ''),
        'actor_id': params.get('actor_id', ''),
        'user': params.get('user', ''),
        'slug': params.get('slug', '')
    }
    kodi_utils.execute_builtin('Container.Update(%s)' %
                               kodi_utils.build_url(url_params))
Exemplo n.º 3
0
 def furkPacks(self, name, file_id, highlight=None, download=False):
     from apis.furk_api import FurkAPI
     kodi_utils.show_busy_dialog()
     t_files = FurkAPI().t_files(file_id)
     t_files = [i for i in t_files if 'video' in i['ct'] and 'bitrate' in i]
     t_files.sort(key=lambda k: k['name'].lower())
     kodi_utils.hide_busy_dialog()
     if download: return t_files
     default_furk_icon = kodi_utils.translate_path(
         'special://home/addons/script.tikiart/resources/media/furk.png')
     list_items = [{
         'line1':
         '%.2f GB | %s' % (float(item['size']) / 1073741824,
                           clean_file_name(item['name']).upper()),
         'icon':
         default_furk_icon
     } for item in t_files]
     kwargs = {
         'items': json.dumps(list_items),
         'heading': name,
         'highlight': highlight,
         'enumerate': 'true',
         'multi_choice': 'false',
         'multi_line': 'false'
     }
     chosen_result = kodi_utils.select_dialog(t_files, **kwargs)
     if chosen_result is None: return None
     link = chosen_result['url_dl']
     name = chosen_result['name']
     return FenPlayer().run(link, 'video')
Exemplo n.º 4
0
 def cast(self):
     key = 'cast'
     if self._action(key) in ('clear', None): return
     from apis.tmdb_api import get_tmdb
     from caches.main_cache import cache_object
     result = None
     actor_id = None
     search_name = None
     search_name = kodi_utils.dialog.input(self.heading_base % ls(32664))
     if not search_name: return
     string = '%s_%s' % ('tmdb_movies_people_search_actor_data',
                         search_name)
     url = 'https://api.themoviedb.org/3/search/person?api_key=%s&language=en-US&query=%s' % (
         self.tmdb_api, search_name)
     result = cache_object(get_tmdb, string, url, 4)
     result = result['results']
     if not result: return
     actor_list = []
     append = actor_list.append
     if len(result) > 1:
         for item in result:
             name = item['name']
             known_for_list = [
                 i.get('title', 'NA') for i in item['known_for']
             ]
             known_for_list = [i for i in known_for_list if not i == 'NA']
             known_for = ', '.join(known_for_list) if known_for_list else ''
             if item.get('profile_path'):
                 icon = 'https://image.tmdb.org/t/p/h632/%s' % item[
                     'profile_path']
             else:
                 icon = kodi_utils.translate_path(
                     'special://home/addons/script.tikiart/resources/media/genre_family.png'
                 )
             append({
                 'line1': name,
                 'line2': known_for,
                 'icon': icon,
                 'name': name,
                 'id': item['id']
             })
         heading = self.heading_base % ls(32664)
         kwargs = {
             'items': json.dumps(actor_list),
             'heading': heading,
             'enumerate': 'false',
             'multi_choice': 'false',
             'multi_line': 'true'
         }
         choice = kodi_utils.select_dialog(actor_list, **kwargs)
         if choice == None: return self._set_property()
         actor_id = choice['id']
         actor_name = choice['name']
     else:
         actor_id = [item['id'] for item in result][0]
         actor_name = [item['name'] for item in result][0]
     if actor_id:
         values = ('&with_cast=%s' % str(actor_id),
                   to_utf8(safe_string(remove_accents(actor_name))))
         self._process(key, values)
Exemplo n.º 5
0
 def clear_cache(self):
     try:
         from modules.kodi_utils import translate_path, clear_property, path_exists
         PM_DATABASE = translate_path(
             'special://profile/addon_data/plugin.video.fen/maincache.db')
         if not path_exists(PM_DATABASE): return True
         import sqlite3 as database
         from caches.debrid_cache import debrid_cache
         user_cloud_success = False
         dbcon = database.connect(PM_DATABASE)
         dbcur = dbcon.cursor()
         # USER CLOUD
         try:
             dbcur.execute("""SELECT id FROM maincache WHERE id LIKE ?""",
                           ('fen_pm_user_cloud%', ))
             try:
                 user_cloud_cache = dbcur.fetchall()
                 user_cloud_cache = [i[0] for i in user_cloud_cache]
             except:
                 user_cloud_success = True
             if not user_cloud_success:
                 for i in user_cloud_cache:
                     dbcur.execute("""DELETE FROM maincache WHERE id=?""",
                                   (i, ))
                     clear_property(str(i))
                 dbcon.commit()
                 user_cloud_success = True
         except:
             user_cloud_success = False
         # DOWNLOAD LINKS
         try:
             dbcur.execute("""DELETE FROM maincache WHERE id=?""",
                           ('fen_pm_transfers_list', ))
             clear_property("fen_pm_transfers_list")
             dbcon.commit()
             download_links_success = True
         except:
             download_links_success = False
         # HOSTERS
         try:
             dbcur.execute("""DELETE FROM maincache WHERE id=?""",
                           ('fen_pm_valid_hosts', ))
             clear_property('fen_pm_valid_hosts')
             dbcon.commit()
             dbcon.close()
             hoster_links_success = True
         except:
             hoster_links_success = False
         # HASH CACHED STATUS
         try:
             debrid_cache.clear_debrid_results('pm')
             hash_cache_status_success = True
         except:
             hash_cache_status_success = False
     except:
         return False
     if False in (user_cloud_success, download_links_success,
                  hoster_links_success, hash_cache_status_success):
         return False
     return True
Exemplo n.º 6
0
def toggle_language_invoker():
    import xml.etree.ElementTree as ET
    from modules.utils import gen_file_hash
    kodi_utils.close_all_dialog()
    kodi_utils.sleep(100)
    addon_dir = kodi_utils.translate_path(
        'special://home/addons/plugin.video.fen')
    addon_xml = os.path.join(addon_dir, 'addon.xml')
    tree = ET.parse(addon_xml)
    root = tree.getroot()
    try:
        current_value = [
            str(i.text) for i in root.iter('reuselanguageinvoker')
        ][0]
    except:
        return
    current_setting = get_setting('reuse_language_invoker')
    new_value = 'false' if current_value == 'true' else 'true'
    if not kodi_utils.confirm_dialog(
            text=ls(33018) % (current_value.upper(), new_value.upper())):
        return
    if new_value == 'true':
        if not kodi_utils.confirm_dialog(text=33019, top_space=True): return
    for item in root.iter('reuselanguageinvoker'):
        item.text = new_value
        hash_start = gen_file_hash(addon_xml)
        tree.write(addon_xml)
        hash_end = gen_file_hash(addon_xml)
        if hash_start != hash_end:
            set_setting('reuse_language_invoker', new_value)
        else:
            return kodi_utils.ok_dialog(text=32574, top_space=True)
    kodi_utils.ok_dialog(text=33020, top_space=True)
    kodi_utils.execute_builtin('LoadProfile(%s)' %
                               kodi_utils.get_infolabel('system.profilename'))
Exemplo n.º 7
0
 def get_provider_and_path(self, provider):
     if provider in info_icons_dict:
         provider_path = info_icons_dict[provider]
     else:
         provider, provider_path = 'folders', translate_path(
             'special://home/addons/plugin.video.fen/resources/skins/Default/media/providers/folders.png'
         )
     return provider, provider_path
Exemplo n.º 8
0
 def _builder():
     for genre, value in sorted(genre_list.items()):
         append(value[0])
         yield {
             'line1': genre,
             'icon':
             kodi_utils.translate_path(icon_directory % value[1])
         }
Exemplo n.º 9
0
def download_directory(db_type):
    if db_type == 'movie': setting = 'movie_download_directory'
    elif db_type == 'episode': setting = 'tvshow_download_directory'
    elif db_type in ('thumb_url', 'image_url', 'image'):
        setting = 'image_download_directory'
    else:
        setting = 'premium_download_directory'
    if get_setting(setting) != '': return translate_path(get_setting(setting))
    else: return False
Exemplo n.º 10
0
 def get_provider_and_path(self):
     provider = lower(self.item.getProperty('tikiskins.provider'))
     if provider in info_icons_dict:
         provider_path = info_icons_dict[provider]
     else:
         provider_path = translate_path(
             'special://home/addons/plugin.video.fen/resources/skins/Default/media/providers/folders.png'
         )
     return provider, provider_path
Exemplo n.º 11
0
def remove_from_history(params):
    cache_file = kodi_utils.translate_path(
        'special://profile/addon_data/plugin.video.fen/maincache.db')
    dbcon = database.connect(cache_file)
    dbcur = dbcon.cursor()
    dbcur.execute("DELETE FROM maincache WHERE id=?", (params['data_id'], ))
    dbcon.commit()
    kodi_utils.clear_property(params['data_id'])
    kodi_utils.execute_builtin('Container.Refresh')
    if not params['silent']: kodi_utils.notification(32576)
Exemplo n.º 12
0
	def _add_misc_dir(url_params, list_name=ls(32799), iconImage='item_next.png', isFolder=True):
		icon = kodi_utils.translate_path('special://home/addons/script.tikiart/resources/media/%s' % iconImage)
		listitem = make_listitem()
		listitem.setLabel(list_name)
		listitem.setArt({'icon': icon, 'poster': icon, 'thumb': icon, 'fanart': fanart, 'banner': icon})
		if url_params['mode'] == 'build_navigate_to_page':
			listitem.setProperty('SpecialSort', 'top')
			listitem.addContextMenuItems([(ls(32784),'RunPlugin(%s)' % build_url({'mode': 'toggle_jump_to'}))])
		else:
			listitem.setProperty('SpecialSort', 'bottom')
		kodi_utils.add_item(__handle__, build_url(url_params), listitem, isFolder)
Exemplo n.º 13
0
def make_settings_dict():
    import xml.etree.ElementTree as ET
    settings_dict = None
    try:
        test_path = translate_path(
            'special://profile/addon_data/plugin.video.fen/')
        profile_dir = 'special://profile/addon_data/plugin.video.fen/%s'
        if not path_exists(test_path): make_directorys(test_path)
        settings_xml = translate_path(profile_dir % 'settings.xml')
        root = ET.parse(settings_xml).getroot()
        settings_dict = {}
        for item in root:
            setting_id = item.get('id')
            setting_value = item.text
            if setting_value is None: setting_value = ''
            dict_item = {setting_id: setting_value}
            settings_dict.update(dict_item)
        set_property('fen_settings', json.dumps(settings_dict))
    except:
        pass
    return settings_dict
Exemplo n.º 14
0
 def debridPacks(self,
                 debrid_provider,
                 name,
                 magnet_url,
                 info_hash,
                 highlight=None,
                 download=False):
     if debrid_provider == 'Real-Debrid':
         from apis.real_debrid_api import RealDebridAPI as debrid_function
         icon = 'realdebrid.png'
     elif debrid_provider == 'Premiumize.me':
         from apis.premiumize_api import PremiumizeAPI as debrid_function
         icon = 'premiumize.png'
     elif debrid_provider == 'AllDebrid':
         from apis.alldebrid_api import AllDebridAPI as debrid_function
         icon = 'alldebrid.png'
     kodi_utils.show_busy_dialog()
     try:
         debrid_files = debrid_function().display_magnet_pack(
             magnet_url, info_hash)
     except:
         debrid_files = None
     kodi_utils.hide_busy_dialog()
     if not debrid_files: return kodi_utils.notification(32574)
     debrid_files.sort(key=lambda k: k['filename'].lower())
     if download: return debrid_files, debrid_function
     default_debrid_icon = kodi_utils.translate_path(
         'special://home/addons/script.tikiart/resources/media/%s' % icon)
     list_items = [{
         'line1':
         '%.2f GB | %s' % (float(item['size']) / 1073741824,
                           clean_file_name(item['filename']).upper()),
         'icon':
         default_debrid_icon
     } for item in debrid_files]
     kwargs = {
         'items': json.dumps(list_items),
         'heading': name,
         'highlight': highlight,
         'enumerate': 'true',
         'multi_choice': 'false',
         'multi_line': 'false'
     }
     chosen_result = kodi_utils.select_dialog(debrid_files, **kwargs)
     if chosen_result is None: return None
     url_dl = chosen_result['link']
     if debrid_provider in ('Real-Debrid', 'AllDebrid'):
         link = debrid_function().unrestrict_link(url_dl)
     elif debrid_provider == 'Premiumize.me':
         link = debrid_function().add_headers_to_url(url_dl)
     name = chosen_result['filename']
     return FenPlayer().run(link, 'video')
Exemplo n.º 15
0
 def _builder():
     for item in results:
         title = item[name_key]
         try:
             year = item[released_key].split('-')[0]
         except:
             year = ''
         if year: rootname = '%s (%s)' % (title, year)
         else: rootname = title
         icon = 'https://image.tmdb.org/t/p/w780%s' % item['poster_path'] if item.get('poster_path') \
                         else kodi_utils.translate_path('special://home/addons/plugin.video.fen/icon.png')
         function_list_append(rootname)
         yield {'line1': rootname, 'line2': item['overview'], 'icon': icon}
Exemplo n.º 16
0
 def similar_recommended(self):
     key = self.key
     if self._action(key) in ('clear', None): return
     title = kodi_utils.dialog.input(self.heading_base % ls(32228))
     if not title: return
     if self.db_type == 'movie':
         from apis.tmdb_api import tmdb_movies_title_year as function
     else:
         from apis.tmdb_api import tmdb_tv_title_year as function
     year = kodi_utils.dialog.input(self.heading_base %
                                    ('%s (%s)' % (ls(32543), ls(32669))),
                                    type=kodi_utils.numeric_input)
     results = function(title, year)['results']
     if len(results) == 0: return kodi_utils.notification(32490)
     choice_list = []
     append = choice_list.append
     for item in results:
         title = item['title'] if self.db_type == 'movie' else item['name']
         try:
             year = item['release_date'].split(
                 '-')[0] if self.db_type == 'movie' else item[
                     'first_air_date'].split('-')[0]
         except:
             year = ''
         if year: rootname = '%s (%s)' % (title, year)
         else: rootname = title
         if item.get('poster_path'):
             icon = 'https://image.tmdb.org/t/p/w780%s' % item['poster_path']
         else:
             icon = kodi_utils.translate_path(
                 'special://home/addons/script.tikiart/resources/media/box_office.png'
             )
         append({
             'line1': rootname,
             'line2': item['overview'],
             'icon': icon,
             'rootname': rootname,
             'tmdb_id': str(item['id'])
         })
     heading = self.heading_base % ('%s %s' % (ls(32193), ls(32228)))
     kwargs = {
         'items': json.dumps(choice_list),
         'heading': heading,
         'enumerate': 'false',
         'multi_choice': 'false',
         'multi_line': 'true'
     }
     values = kodi_utils.select_dialog([(i['tmdb_id'], i['rootname'])
                                        for i in choice_list], **kwargs)
     if values == None: return
     self._process(key, values)
Exemplo n.º 17
0
def scraper_names(folder):
    providerList = []
    append = providerList.append
    source_folder_location = 'special://home/addons/script.module.fenomscrapers/lib/fenomscrapers/sources_fenomscrapers/%s'
    sourceSubFolders = ('hosters', 'torrents')
    if folder != 'all':
        sourceSubFolders = [i for i in sourceSubFolders if i == folder]
    for item in sourceSubFolders:
        files = kodi_utils.list_dirs(
            kodi_utils.translate_path(source_folder_location % item))[1]
        for m in files:
            module_name = m.split('.')[0]
            if module_name == '__init__': continue
            append(module_name)
    return providerList
Exemplo n.º 18
0
def refresh_artwork():
    if not kodi_utils.confirm_dialog(): return
    import sqlite3 as database
    for item in ('icon.png', 'fanart.png'):
        try:
            icon_path = kodi_utils.translate_path(
                'special://home/addons/plugin.video.fen/%s' % item)
            thumbs_folder = kodi_utils.translate_path('special://thumbnails')
            TEXTURE_DB = kodi_utils.translate_path(
                'special://database/Textures13.db')
            dbcon = database.connect(TEXTURE_DB)
            dbcur = dbcon.cursor()
            dbcur.execute("SELECT cachedurl FROM texture WHERE url = ?",
                          (icon_path, ))
            image = dbcur.fetchone()[0]
            dbcon.close()
            removal_path = os.path.join(thumbs_folder, image)
            kodi_utils.delete_file(removal_path)
        except:
            pass
    kodi_utils.sleep(200)
    kodi_utils.execute_builtin('ReloadSkin()')
    kodi_utils.sleep(500)
    kodi_utils.notification(32576)
Exemplo n.º 19
0
 def import_info():
     files = kodi_utils.list_dirs(
         kodi_utils.translate_path(
             'special://home/addons/plugin.video.fen/resources/lib/scrapers'
         ))[1]
     for item in files:
         try:
             module_name = item.split('.')[0]
             if module_name in ('__init__', 'external', 'folders'): continue
             if module_name not in active_sources: continue
             if prescrape and not check_prescrape_sources(module_name):
                 continue
             module = manual_function_import('scrapers.%s' % module_name,
                                             'source')
             yield ('internal', module, module_name)
         except:
             pass
Exemplo n.º 20
0
def clear_media_results_database():
    import sqlite3 as database
    from modules.kodi_utils import translate_path, clear_property
    FURK_DATABASE = translate_path(
        'special://profile/addon_data/plugin.video.fen/maincache.db')
    dbcon = database.connect(FURK_DATABASE)
    dbcur = dbcon.cursor()
    dbcur.execute("SELECT id FROM maincache WHERE id LIKE 'fen_FURK_SEARCH_%'")
    try:
        furk_results = [str(i[0]) for i in dbcur.fetchall()]
        if not furk_results: return 'success'
        dbcur.execute(
            "DELETE FROM maincache WHERE id LIKE 'fen_FURK_SEARCH_%'")
        dbcon.commit()
        for i in furk_results:
            clear_property(i)
        return 'success'
    except:
        return 'failed'
Exemplo n.º 21
0
def clear_imdb_cache(silent=False):
    import sqlite3 as database
    from modules.kodi_utils import translate_path, path_exists, clear_property
    try:
        IMDB_DATABASE = translate_path(
            'special://profile/addon_data/plugin.video.fen/maincache.db')
        if not path_exists(IMDB_DATABASE): return True
        dbcon = database.connect(IMDB_DATABASE)
        dbcur = dbcon.cursor()
        dbcur.execute("SELECT id FROM maincache WHERE id LIKE ?", ('imdb_%', ))
        imdb_results = [str(i[0]) for i in dbcur.fetchall()]
        if not imdb_results: return True
        dbcur.execute("DELETE FROM maincache WHERE id LIKE ?", ('imdb_%', ))
        dbcon.commit()
        dbcon.close()
        for i in imdb_results:
            clear_property(i)
        return True
    except:
        return False
Exemplo n.º 22
0
 def clear_cache(self):
     try:
         AD_DATABASE = kodi_utils.translate_path(
             'special://profile/addon_data/plugin.video.fen/maincache.db')
         if not kodi_utils.path_exists(AD_DATABASE): return True
         from caches.debrid_cache import debrid_cache
         dbcon = database.connect(AD_DATABASE)
         dbcur = dbcon.cursor()
         # USER CLOUD
         try:
             dbcur.execute("""DELETE FROM maincache WHERE id=?""",
                           ('fen_ad_user_cloud', ))
             kodi_utils.clear_property('fen_ad_user_cloud')
             dbcon.commit()
             user_cloud_success = True
         except:
             user_cloud_success = False
         # HOSTERS
         try:
             dbcur.execute("""DELETE FROM maincache WHERE id=?""",
                           ('fen_ad_valid_hosts', ))
             kodi_utils.clear_property('fen_ad_valid_hosts')
             dbcon.commit()
             dbcon.close()
             hoster_links_success = True
         except:
             hoster_links_success = False
         # HASH CACHED STATUS
         try:
             debrid_cache.clear_debrid_results('ad')
             hash_cache_status_success = True
         except:
             hash_cache_status_success = False
     except:
         return False
     if False in (user_cloud_success, hoster_links_success,
                  hash_cache_status_success):
         return False
     return True
Exemplo n.º 23
0
def trakt_manager_choice(params):
    if not get_setting('trakt_user', ''):
        return kodi_utils.notification(32760, 3500)
    icon = kodi_utils.translate_path(
        'special://home/addons/script.tikiart/resources/media/trakt.png')
    choices = [('%s %s...' % (ls(32602), ls(32199)), 'Add'),
               ('%s %s...' % (ls(32603), ls(32199)), 'Remove')]
    list_items = [{'line1': item[0], 'icon': icon} for item in choices]
    kwargs = {
        'items': json.dumps(list_items),
        'heading': ls(32198).replace('[B]', '').replace('[/B]', ''),
        'enumerate': 'false',
        'multi_choice': 'false',
        'multi_line': 'false'
    }
    choice = kodi_utils.select_dialog([i[1] for i in choices], **kwargs)
    if choice == None: return
    if choice == 'Add':
        from apis.trakt_api import trakt_add_to_list
        trakt_add_to_list(params)
    else:
        from apis.trakt_api import trakt_remove_from_list
        trakt_remove_from_list(params)
Exemplo n.º 24
0
# -*- coding: utf-8 -*-
import os
import json
from urllib.parse import unquote
from apis.tmdb_api import tmdb_people_info
from windows import open_window
from indexers.images import Images
from modules.kodi_utils import translate_path, select_dialog, dialog
# from modules.kodi_utils import logger

icon_directory = translate_path('special://home/addons/script.tikiart/resources/media')
tmdb_image_url = 'https://image.tmdb.org/t/p/h632/%s'

def popular_people():
	Images().run({'mode': 'popular_people_image_results', 'page_no': 1})

def person_data_dialog(params):
	if 'query' in params: query = unquote(params['query'])
	else: query = None
	open_window(['windows.people', 'People'], 'people.xml',
				query=params.get('query', None), actor_name=params.get('actor_name'), actor_image=params.get('actor_image'), actor_id=params.get('actor_id'))

def person_search(actor_name=None):
	def _get_actor_details():
		from modules.history import add_to_search_history
		try: actors = tmdb_people_info(query)
		except: return None, None, None
		if len(actors) == 1:
			actors = actors[0]
			actor_id = actors['id']
			actor_name = actors['name']
Exemplo n.º 25
0
 def help(self):
     text_file = kodi_utils.translate_path(
         'special://home/addons/plugin.video.fen/resources/text/tips/135. Fen Discover.txt'
     )
     return kodi_utils.show_text(self.heading_base % ls(32487),
                                 file=text_file)
Exemplo n.º 26
0
    def history(self, db_type=None, display=True):
        def _builder():
            for count, item in enumerate(data):
                try:
                    cm = []
                    cm_append = cm.append
                    data_id = history[count][0]
                    name = item['name']
                    url_params = {
                        'mode': item['mode'],
                        'action': item['action'],
                        'query': item['query'],
                        'name': name,
                        'iconImage': default_icon
                    }
                    display = '%s | %s' % (count + 1, name)
                    url = build_url(url_params)
                    remove_single_params = {
                        'mode': 'discover.remove_from_history',
                        'data_id': data_id
                    }
                    remove_all_params = {
                        'mode': 'discover.remove_all_history',
                        'db_type': db_type
                    }
                    export_params = {
                        'mode': 'navigator.adjust_main_lists',
                        'method': 'add_external',
                        'list_name': name,
                        'menu_item': json.dumps(url_params)
                    }
                    listitem = make_listitem()
                    listitem.setLabel(display)
                    listitem.setArt({
                        'icon': default_icon,
                        'poster': default_icon,
                        'thumb': default_icon,
                        'fanart': fanart,
                        'banner': default_icon
                    })
                    cm_append(
                        ('[B]%s[/B]' % export_str,
                         'RunPlugin(%s)' % self._build_url(export_params)))
                    cm_append(('[B]%s[/B]' % remove_str, 'RunPlugin(%s)' %
                               self._build_url(remove_single_params)))
                    cm_append(
                        ('[B]%s[/B]' % clear_str,
                         'RunPlugin(%s)' % self._build_url(remove_all_params)))
                    listitem.addContextMenuItems(cm)
                    yield (url, listitem, True)
                except:
                    pass

        __handle__ = int(argv[1])
        cache_file = kodi_utils.translate_path(
            'special://profile/addon_data/plugin.video.fen/maincache.db')
        db_type = db_type if db_type else self.db_type
        string = 'fen_discover_%s_%%' % db_type
        dbcon = database.connect(cache_file)
        dbcur = dbcon.cursor()
        dbcur.execute(
            "SELECT id, data FROM maincache WHERE id LIKE ? ORDER BY rowid DESC",
            (string, ))
        history = dbcur.fetchall()
        if not display: return [i[0] for i in history]
        data = [eval(i[1]) for i in history]
        export_str = ls(32697)
        remove_str = ls(32698)
        clear_str = ls(32699)
        item_list = list(_builder())
        kodi_utils.add_items(__handle__, item_list)
        self._end_directory()
Exemplo n.º 27
0
import json
from sys import argv
import sqlite3 as database
from urllib.parse import urlencode
from modules import kodi_utils
from modules import meta_lists
from modules.utils import to_utf8, safe_string, remove_accents
from modules import settings
# from modules.kodi_utils import logger

ls = kodi_utils.local_string
build_url = kodi_utils.build_url
make_listitem = kodi_utils.make_listitem
icon_directory = 'special://home/addons/script.tikiart/resources/media/%s'
default_icon = kodi_utils.translate_path(
    'special://home/addons/script.tikiart/resources/media/discover.png')
fanart = kodi_utils.translate_path(
    'special://home/addons/plugin.video.fen/fanart.png')
listitem_position = {
    'similar': 0,
    'recommended': 0,
    'year_start': 3,
    'year_end': 4,
    'include_genres': 5,
    'exclude_genres': 6,
    'include_keywords': 7,
    'exclude_keywords': 8,
    'language': 9,
    'region': 10,
    'network': 10,
    'companies': 11,
Exemplo n.º 28
0
def runner(params):
    kodi_utils.show_busy_dialog()
    threads = []
    append = threads.append
    action = params.get('action')
    if action == 'meta.single':
        Downloader(params).run()
    elif action == 'image':
        for item in ('thumb_url', 'image_url'):
            image_params = params
            image_params['url'] = params.pop(item)
            image_params['db_type'] = item
            Downloader(image_params).run()
    elif action.startswith('cloud'):
        Downloader(params).run()
    elif action == 'meta.pack':
        from modules.source_utils import find_season_in_release_title
        provider = params['provider']
        if provider == 'furk':
            try:
                t_files = Sources().furkPacks(params['file_name'],
                                              params['file_id'],
                                              download=True)
                pack_choices = [
                    dict(
                        params, **{
                            'pack_files': {
                                'link': item['url_dl'],
                                'filename': item['name'],
                                'size': item['size']
                            }
                        }) for item in t_files
                ]
                icon = 'furk.png'
            except:
                return kodi_utils.notification(32692)
        else:
            try:
                debrid_files, debrid_function = Sources().debridPacks(
                    provider,
                    params['name'],
                    params['magnet_url'],
                    params['info_hash'],
                    download=True)
                pack_choices = [
                    dict(params, **{'pack_files': item})
                    for item in debrid_files
                ]
                icon = {
                    'Real-Debrid': 'realdebrid.png',
                    'Premiumize.me': 'premiumize.png',
                    'AllDebrid': 'alldebrid.png'
                }[provider]
            except:
                return kodi_utils.notification(32692)
        default_icon = kodi_utils.translate_path(
            'special://home/addons/script.tikiart/resources/media/%s' % icon)
        chosen_list = select_pack_item(pack_choices, params['highlight'],
                                       default_icon)
        if not chosen_list: return
        if provider == 'furk': show_package = True
        else:
            show_package = json.loads(
                params['source']).get('package') == 'show'
        meta = json.loads(chosen_list[0].get('meta'))
        default_name = '%s (%s)' % (clean_file_name(
            get_title(meta)), meta.get('year'))
        default_foldername = kodi_utils.dialog.input(ls(32228),
                                                     defaultt=default_name)
        for item in chosen_list:
            if show_package:
                season = find_season_in_release_title(
                    item['pack_files']['filename'])
                if season:
                    meta['season'] = season
                    item['meta'] = json.dumps(meta)
                    item['default_foldername'] = default_foldername
                else:
                    pass
            append(Thread(target=Downloader(item).run))
        [i.start() for i in threads]
Exemplo n.º 29
0
import json
import ssl
from threading import Thread
from urllib.parse import unquote, parse_qsl, urlparse
from urllib.request import Request, urlopen
from modules import kodi_utils
from modules.sources import Sources
from modules.utils import clean_file_name, clean_title, to_utf8, safe_string, remove_accents
from modules.settings_reader import get_setting
from modules.settings import download_directory, get_art_provider
# from modules.kodi_utils import logger

ls = kodi_utils.local_string
ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
levels = ['../../../..', '../../..', '../..', '..']
poster_empty = kodi_utils.translate_path(
    'special://home/addons/script.tikiart/resources/media/box_office.png')
video_extensions = ('m4v', '3g2', '3gp', 'nsv', 'tp', 'ts', 'ty', 'pls', 'rm',
                    'rmvb', 'mpd', 'ifo', 'mov', 'qt', 'divx', 'xvid', 'bivx',
                    'vob', 'nrg', 'img', 'iso', 'udf', 'pva', 'wmv', 'asf',
                    'asx', 'ogm', 'm2v', 'avi', 'bin', 'dat', 'mpg', 'mpeg',
                    'mp4', 'mkv', 'mk3d', 'avc', 'vp3', 'svq3', 'nuv', 'viv',
                    'dv', 'fli', 'flv', 'wpl', 'xspf', 'vdr', 'dvr-ms', 'xsp',
                    'mts', 'm2t', 'm2ts', 'evo', 'ogv', 'sdp', 'avs', 'rec',
                    'url', 'pxml', 'vc1', 'h264', 'rcv', 'rss', 'mpls', 'mpl',
                    'webm', 'bdmv', 'bdm', 'wtv', 'trp', 'f4v', 'pvr', 'disc')
audio_extensions = ('wav', 'mp3', 'ogg', 'flac', 'wma', 'aac')
image_extensions = ('jpg', 'jpeg', 'jpe', 'jif', 'jfif', 'jfi', 'bmp', 'dib',
                    'png', 'gif', 'webp', 'tiff', 'tif', 'psd', 'raw', 'arw',
                    'cr2', 'nrw', 'k25', 'jp2', 'j2k', 'jpf', 'jpx', 'jpm',
                    'mj2')
Exemplo n.º 30
0
# -*- coding: utf-8 -*-
import sqlite3 as database
from modules.kodi_utils import translate_path
from modules.utils import to_utf8
# from modules.kodi_utils import logger

dbfile = translate_path(
    'special://profile/addon_data/plugin.video.fen/imagehash.db')
timeout = 240

GET_IMAGE = 'SELECT hash, brightness FROM imagehash_data WHERE image = ?'
SET_IMAGE = 'INSERT OR REPLACE INTO imagehash_data VALUES (?, ?, ?)'


class ImagehashCache():
    def get(self, image_path):
        result = None
        try:
            dbcon = self.connect_database()
            dbcur = self.set_PRAGMAS(dbcon)
            dbcur.execute(GET_IMAGE, (image_path, ))
            cache_data = dbcur.fetchone()
            if cache_data: result = cache_data
        except:
            pass
        return result

    def set(self, image_path, data):
        try:
            dbcon = self.connect_database()
            dbcur = self.set_PRAGMAS(dbcon)