示例#1
0
def get_active_downloads():
    from datetime import timedelta
    from modules import fen_cache
    _cache = fen_cache.FenCache()
    cache = _cache.get('furk_active_downloads')
    if cache != None: result = cache
    else:
        active_downloads = Furk.file_get_active()
        result = [i['info_hash'] for i in active_downloads]
        _cache.set('furk_active_downloads', result, expiration=timedelta(hours=1))
    return result
示例#2
0
 def get_active_downloads(self):
     _cache = fen_cache.FenCache()
     cache = _cache.get('furk_active_downloads')
     if cache != None: result = cache
     else:
         active_downloads = Furk.file_get_active()
         result = [i['info_hash'] for i in active_downloads]
         _cache.set('furk_active_downloads',
                    result,
                    expiration=timedelta(hours=1))
     return result
示例#3
0
def torrent_status_browser(files):
    from datetime import timedelta
    from modules import fen_cache
    for count, item in enumerate(files, 1):
        try:
            display = '%02d | %s | [COLOR=grey][I]%s | %sGB | %s %% | SPEED: %s kB/s | (S:%s P:%s)[/I][/COLOR]' % (count, item['name'].replace('magnet:', '').upper(), item['dl_status'].upper(), str(round(float(item['size'])/1048576000, 1)), item['have'], str(round(float(item['speed'])/1024, 1)), item['seeders'], item['peers'])
            url_params = {'mode': 'furk.remove_from_downloads', 'name': item['name'], 'id': item['id']}
            url = build_url(url_params)
            listitem = xbmcgui.ListItem(display)
            listitem.setArt({'icon': default_furk_icon, 'poster': default_furk_icon, 'thumb': default_furk_icon, 'fanart': fanart, 'banner': default_furk_icon})
            xbmcplugin.addDirectoryItem(__handle__, url, listitem, isFolder=True)
        except: pass
    fen_cache.FenCache().set('furk_active_downloads', [i['info_hash'] for i in files], expiration=timedelta(hours=1))
    xbmcplugin.setContent(__handle__, 'files')
    xbmcplugin.endOfDirectory(__handle__)
    setView('view.premium')
示例#4
0
def set_history(db_type, name, query):
    from modules import fen_cache
    from datetime import timedelta
    _cache = fen_cache.FenCache()
    string = 'fen_discover_%s_%s' % (db_type, query)
    cache = _cache.get(string)
    if cache: return
    if db_type == 'movie':
        mode = 'build_movie_list'
        action = 'tmdb_movies_discover'
    else:
        mode = 'build_tvshow_list'
        action = 'tmdb_tv_discover'
    data = {'mode': mode, 'action': action, 'name': name, 'query': query}
    _cache.set(string, data, expiration=timedelta(days=7))
    return
示例#5
0
def add_uncached_file(name=None, item_id=None):
    params = dict(parse_qsl(sys.argv[2].replace('?','')))
    name = params.get('name', name)
    item_id = params.get('id', item_id)
    if not dialog.yesno("Fen", '[B][I]%s[/I][/B]' % name, '', 'Add this uncached torrent to your Furk Files?', 'No','Yes'):
        return
    try:
        response = Furk.add_uncached(item_id)
        if response['status'] == 'ok':
            from datetime import timedelta
            from modules import fen_cache
            fen_cache.FenCache().set('furk_active_downloads', None, expiration=timedelta(hours=1))
            dialog.ok('Fen', '[COLOR=green][B]SUCCESS.[/B][/COLOR]', '[B][I]%s[/I][/B]' % name, 'Torrent added')
        elif response['status'] == 'error':
            dialog.ok('Fen', '[COLOR=red][B]FAIL.[/B][/COLOR]', '[B][I]%s[/I][/B]' % name, 'Error adding torrent')
            return
    except: return
示例#6
0
def remove_from_downloads(name='', item_id=''):
    from modules.nav_utils import notification
    params = dict(parse_qsl(sys.argv[2].replace('?','')))
    name = params.get('name', name)
    item_id = params.get('id', item_id)
    resp = dialog.yesno('Furk It', "[B][I]%s[/I][/B]" % name, "", "Remove from My Furk Downloads?")
    if resp:
        response = Furk.download_unlink(item_id)
        if response['status'] == 'ok':
            from datetime import timedelta
            from modules import fen_cache
            fen_cache.FenCache().set('furk_active_downloads', None, expiration=timedelta(hours=1))
            dialog.ok('Fen', '[COLOR=green][B]SUCCESS.[/B][/COLOR]', '[B][I]%s[/I][/B]' % name, 'Torrent removed')
        else:
            dialog.ok('Fen', '[COLOR=red][B]FAIL.[/B][/COLOR]', '[B][I]%s[/I][/B]' % name, 'Error removing torrent')
        return (None, None)
        dialog.close()
    else: return
示例#7
0
import re
import json
import os
from threading import Thread
from apis.alldebrid_api import AllDebridAPI
from modules import fen_cache
from modules.utils import get_release_quality, get_file_info, clean_title, clean_file_name, normalize, supported_video_extensions
from scrapers import build_internal_scrapers_label, label_settings
from modules import settings
# from modules.utils import logger

__addon__ = xbmcaddon.Addon(id='plugin.video.fen')
window = xbmcgui.Window(10000)

AllDebrid = AllDebridAPI()
_cache = fen_cache.FenCache()


class AllDebridSource:
    def __init__(self):
        self.scrape_provider = 'ad-cloud'
        self.sources = []
        self.folder_results = []
        self.scrape_results = []

    def results(self, info):
        try:
            self.info = info
            self.db_type = self.info.get("db_type")
            self.title = self.info.get("title")
            self.year = self.info.get("year")
示例#8
0
def debrid_link_folders(debrid_service, folder_name, action):
    import xbmcgui
    from modules import fen_cache
    dialog = xbmcgui.Dialog()
    _cache = fen_cache.FenCache()
    string = 'FEN_%s_%s' % (debrid_service, folder_name)
    check_show = _cache.get(string)
    profile_dir = xbmc.translatePath(__addon__.getAddonInfo('profile'))
    if action == 'remove':
        if not check_show:
            return dialog.ok('FEN DEBRID', 'No TV Show Linked to this Folder.')
        if not dialog.yesno('FEN DEBRID',
                            'Clear Link to [B]%s[/B]?' % check_show):
            return
        from modules.settings import check_database
        try:
            from sqlite3 import dbapi2 as database
        except ImportError:
            from pysqlite2 import dbapi2 as database
        window = xbmcgui.Window(10000)
        cache_file = os.path.join(profile_dir, "fen_cache.db")
        check_database(cache_file)
        dbcon = database.connect(cache_file)
        dbcur = dbcon.cursor()
        dbcur.execute("DELETE FROM fencache WHERE id=?", (string, ))
        dbcon.commit()
        window.clearProperty(string)
        return dialog.ok('FEN DEBRID', 'Link Removed.')
    if check_show:
        if not dialog.yesno(
                'FEN DEBRID', 'This Folder is Already Linked to a TV Show:',
                '[B]%s[/B]' % check_show,
                'Do you wish to Link this Folder to a Different Show?'):
            return
    title = dialog.input("Enter TV Show Title").lower()
    if not title: return
    from apis.tmdb_api import tmdb_tv_title_year
    year = dialog.input("Enter Year (Optional)", type=xbmcgui.INPUT_NUMERIC)
    results = tmdb_tv_title_year(title, year)['results']
    if len(results) == 0:
        return dialog.ok('FEN DEBRID', 'No Matching Titles to Select.',
                         'Please Try a Different Search Term.')
    choice_list = []
    for item in results:
        title = item['name']
        try:
            year = item['first_air_date'].split('-')[0]
        except:
            year = ''
        if year: rootname = '%s (%s)' % (title, year)
        else: rootname = title
        line1 = rootname
        line2 = '[I]%s[/I]' % item['overview']
        icon = 'http://image.tmdb.org/t/p/w92%s' % item[
            'poster_path'] if item.get('poster_path') else xbmc.translatePath(
                __addon__.getAddonInfo('icon'))
        listitem = xbmcgui.ListItem(line1, line2)
        listitem.setArt({'icon': icon})
        listitem.setProperty('rootname', rootname)
        choice_list.append(listitem)
    chosen_title = dialog.select("FEN DEBRID: Select Correct Title",
                                 choice_list,
                                 useDetails=True)
    if chosen_title < 0: return
    from datetime import timedelta
    rootname = choice_list[chosen_title].getProperty('rootname')
    _cache.set(string, rootname, expiration=timedelta(days=60))
    return dialog.ok('FEN DEBRID', '[B]%s[/B]' % rootname,
                     'Linked to this Folder.')