def __init__(self):
     movie_library = os.path.join(control.transPath(control.setting('movie_library')),'')
     tv_library = os.path.join(control.transPath(control.setting('tv_library')),'')
     tv_downloads = os.path.join(control.transPath(control.setting('tv_downloads')),'')
     #movie_downloads = os.path.join(control.transPath(control.setting('movie_downloads')),'')
     if not os.path.exists(movie_library): os.makedirs(movie_library)
     if not os.path.exists(tv_library): os.makedirs(tv_library)
示例#2
0
def download(name, image, url):

    if type(url) is list:
        url = url[0]

    from resources.lib.libraries import control

    if url == None:
        return control.infoDialog(control.lang(30501).encode('utf-8'))

    try: headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1]))
    except: headers = dict('')

    url = url.split('|')[0]

    content = re.compile('(.+?)\sS(\d*)E\d*$').findall(name)
    transname = name.translate(None, '\/:*?"<>|').strip('.')
    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)
        transtvshowtitle = content[0][0].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)

    sysheaders = urllib.quote_plus(json.dumps(headers))

    sysurl = urllib.quote_plus(url)

    systitle = urllib.quote_plus(name)

    sysimage = urllib.quote_plus(image)

    sysdest = urllib.quote_plus(dest)

    script = inspect.getfile(inspect.currentframe())
    cmd = 'RunScript(%s, %s, %s, %s, %s, %s)' % (script, sysurl, sysdest, systitle, sysimage, sysheaders)

    xbmc.executebuiltin(cmd)
示例#3
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting('movie_library')),'')

        self.check_setting = control.setting('check_movie_link') or 'false'
        self.library_setting = control.setting('update_library') or 'true'
        self.dupe_setting = control.setting('check_library') or 'true'

        self.infoDialog = False
示例#4
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting("movie_library")), "")

        self.check_setting = control.setting("check_movie_link") or "false"
        self.library_setting = control.setting("update_library") or "true"
        self.dupe_setting = control.setting("check_library") or "true"

        self.infoDialog = False
示例#5
0
    def __init__(self):
        movie_library = os.path.join(
            control.transPath(control.setting('movie_library')), '')
        tv_library = os.path.join(
            control.transPath(control.setting('tv_library')), '')
        tv_downloads = os.path.join(
            control.transPath(control.setting('tv_downloads')), '')
        movie_downloads = os.path.join(
            control.transPath(control.setting('movie_downloads')), '')

        try:
            if not os.path.exists(movie_library): os.makedirs(movie_library)
        except:
            pass
        try:
            if not os.path.exists(tv_library): os.makedirs(tv_library)
        except:
            pass
示例#6
0
    def __init__(self):
        self.library_folder = os.path.join(
            control.transPath(control.setting('movie_library')), '')

        self.check_setting = control.setting('check_movie_link') or 'false'
        self.library_setting = control.setting('update_library') or 'true'
        self.dupe_setting = control.setting('check_library') or 'true'

        self.infoDialog = False
示例#7
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting('tv_library')),'')

        self.library_setting = control.setting('update_library') or 'true'
        self.property = '%s_service_property' % control.addonInfo('name').lower()

        self.datetime = (datetime.datetime.utcnow() - datetime.timedelta(hours = 5))
        self.date = (self.datetime - datetime.timedelta(hours = 24)).strftime('%Y%m%d')

        self.infoDialog = False
示例#8
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting('tv_library')),'')

        self.library_setting = control.setting('update_library') or 'true'
        self.property = '%s_service_property' % control.addonInfo('name').lower()

        self.datetime = (datetime.datetime.utcnow() - datetime.timedelta(hours = 5))
        self.date = (self.datetime - datetime.timedelta(hours = 24)).strftime('%Y%m%d')

        self.infoDialog = False
示例#9
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting("tv_library")), "")

        self.library_setting = control.setting("update_library") or "true"
        self.property = "%s_service_property" % control.addonInfo("name").lower()

        self.datetime = datetime.datetime.utcnow() - datetime.timedelta(hours=5)
        self.date = (self.datetime - datetime.timedelta(hours=24)).strftime("%Y%m%d")

        self.infoDialog = False
示例#10
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting('tv_library')),'')

        self.check_setting = control.setting('check_episode_link') or 'false'
        self.library_setting = control.setting('update_library') or 'true'
        self.dupe_setting = control.setting('check_library') or 'true'

        self.datetime = (datetime.datetime.utcnow() - datetime.timedelta(hours = 5))
        self.date = (self.datetime - datetime.timedelta(hours = 24)).strftime('%Y%m%d')

        self.infoDialog = False
        self.block = False
示例#11
0
文件: libtools.py 项目: mpie/repo
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting('tv_library')),'')

        self.check_setting = control.setting('check_episode_link') or 'false'
        self.library_setting = control.setting('update_library') or 'true'
        self.dupe_setting = control.setting('check_library') or 'true'

        self.datetime = (datetime.datetime.utcnow() - datetime.timedelta(hours = 5))
        self.date = (self.datetime - datetime.timedelta(hours = 24)).strftime('%Y%m%d')

        self.infoDialog = False
        self.block = False
示例#12
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting("tv_library")), "")

        self.version = control.version()

        self.check_setting = control.setting("check_episode_link") or "false"
        self.library_setting = control.setting("update_library") or "true"
        self.dupe_setting = control.setting("check_library") or "true"

        self.datetime = datetime.datetime.utcnow() - datetime.timedelta(hours=5)
        self.date = (self.datetime - datetime.timedelta(hours=24)).strftime("%Y%m%d")

        self.infoDialog = False
        self.block = False
示例#13
0
    def __init__(self):
        self.library_folder = os.path.join(
            control.transPath(control.setting('library.tv')), '')

        self.version = control.version()

        self.check_setting = control.setting(
            'library.check_episode') or 'false'
        self.include_unknown = control.setting(
            'library.include_unknown') or 'true'
        self.library_setting = control.setting('library.update') or 'true'
        self.dupe_setting = control.setting('library.check') or 'true'

        self.datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(hours=5))
        self.date = (self.datetime -
                     datetime.timedelta(hours=24)).strftime('%Y%m%d')
        self.silentDialog = False
        self.infoDialog = False
        self.block = False
示例#14
0
def download(name, image, url):

    if type(url) is list:
        url = url[0]

    from resources.lib.libraries import control

    if url == None:
        return control.infoDialog(control.lang(30501).encode('utf-8'))

    try:
        headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1]))
    except:
        headers = dict('')

    url = url.split('|')[0]

    content = re.compile('(.+?)\sS(\d*)E\d*$').findall(name)
    transname = name.translate(None, '\/:*?"<>|').strip('.')
    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)
        transtvshowtitle = content[0][0].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)

    sysheaders = urllib.quote_plus(json.dumps(headers))

    sysurl = urllib.quote_plus(url)

    systitle = urllib.quote_plus(name)

    sysimage = urllib.quote_plus(image)

    sysdest = urllib.quote_plus(dest)

    script = inspect.getfile(inspect.currentframe())
    cmd = 'RunScript(%s, %s, %s, %s, %s, %s)' % (
        script, sysurl, sysdest, systitle, sysimage, sysheaders)

    xbmc.executebuiltin(cmd)
示例#15
0
    def service(self):
        try:
            lib_tools.create_folder(
                os.path.join(
                    control.transPath(control.setting('library.movie')), ''))
            lib_tools.create_folder(
                os.path.join(control.transPath(control.setting('library.tv')),
                             ''))
        except:
            pass

        try:
            control.makeFile(control.dataPath)
            dbcon = database.connect(control.libcacheFile)
            dbcur = dbcon.cursor()
            dbcur.execute("CREATE TABLE IF NOT EXISTS service ("
                          "setting TEXT, "
                          "value TEXT, "
                          "UNIQUE(setting)"
                          ");")
            dbcur.execute("SELECT * FROM service WHERE setting = 'last_run'")
            fetch = dbcur.fetchone()
            if fetch == None:
                serviceProperty = "1970-01-01 23:59:00.000000"
                dbcur.execute("INSERT INTO service Values (?, ?)",
                              ('last_run', serviceProperty))
                dbcon.commit()
            else:
                serviceProperty = str(fetch[1])
            dbcon.close()
        except:
            try:
                return dbcon.close()
            except:
                return

        try:
            control.window.setProperty(self.property, serviceProperty)
        except:
            return

        while not xbmc.abortRequested:
            try:
                serviceProperty = control.window.getProperty(self.property)

                t1 = datetime.timedelta(hours=6)
                t2 = datetime.datetime.strptime(serviceProperty,
                                                '%Y-%m-%d %H:%M:%S.%f')
                t3 = datetime.datetime.now()

                check = abs(t3 - t2) > t1
                if check == False: raise Exception()

                if (control.player.isPlaying()
                        or control.condVisibility('Library.IsScanningVideo')):
                    raise Exception()

                serviceProperty = datetime.datetime.now().strftime(
                    '%Y-%m-%d %H:%M:%S.%f')

                control.window.setProperty(self.property, serviceProperty)

                try:
                    dbcon = database.connect(control.libcacheFile)
                    dbcur = dbcon.cursor()
                    dbcur.execute("CREATE TABLE IF NOT EXISTS service ("
                                  "setting TEXT, "
                                  "value TEXT, "
                                  "UNIQUE(setting)"
                                  ");")
                    dbcur.execute(
                        "DELETE FROM service WHERE setting = 'last_run'")
                    dbcur.execute("INSERT INTO service Values (?, ?)",
                                  ('last_run', serviceProperty))
                    dbcon.commit()
                    dbcon.close()
                except:
                    try:
                        dbcon.close()
                    except:
                        pass

                if not control.setting('library.service.update') == 'true':
                    raise Exception()
                info = control.setting(
                    'library.service.notification') or 'true'
                self.update(info=info)
            except:
                pass

            control.sleep(10000)