Exemple #1
0
    def range(self, url):
        control.idle()

        yes = control.yesnoDialog(control.lang(32555).encode('utf-8'), '', '')
        if not yes: return

        if not control.condVisibility(
                'Window.IsVisible(infodialog)') and not control.condVisibility(
                    'Player.HasVideo'):
            control.infoDialog(control.lang(32552).encode('utf-8'),
                               time=10000000)
            self.infoDialog = True

        from resources.lib.indexers import tvshows
        items = tvshows.tvshows().get(url, idx=False)
        if items == None: items = []

        for i in items:
            try:
                if xbmc.abortRequested == True: return sys.exit()
                self.add(i['title'],
                         i['year'],
                         i['imdb'],
                         i['tvdb'],
                         range=True)
            except:
                pass

        if self.infoDialog == True:
            control.infoDialog(control.lang(32554).encode('utf-8'), time=1)

        if self.library_setting == 'true' and not control.condVisibility(
                'Library.IsScanningVideo'):
            control.execute('UpdateLibrary(video)')
Exemple #2
0
    def get(self, name, year='0'):
        try:
            offset = '0'

            if not control.setting('bookmarks') == 'true': raise Exception()

            idFile = hashlib.md5()
            for i in name: idFile.update(str(i))
            for i in year: idFile.update(str(i))
            idFile = str(idFile.hexdigest())

            dbcon = database.connect(control.bookmarksFile)
            dbcur = dbcon.cursor()
            dbcur.execute("SELECT * FROM bookmark WHERE idFile = '%s'" % idFile)
            match = dbcur.fetchone()
            self.offset = str(match[1])
            dbcon.commit()

            if self.offset == '0': raise Exception()

            minutes, seconds = divmod(float(self.offset), 60) ; hours, minutes = divmod(minutes, 60)
            label = '%02d:%02d:%02d' % (hours, minutes, seconds)
            label = (control.lang(32502) % label).encode('utf-8')

            try: yes = control.dialog.contextmenu([label, control.lang(32501).encode('utf-8'), ])
            except: yes = control.yesnoDialog(label, '', '', str(name), control.lang(32503).encode('utf-8'), control.lang(32501).encode('utf-8'))

            if yes: self.offset = '0'

            return self.offset
        except:
            return offset
Exemple #3
0
 def clearCacheAll(self):
     control.idle()
     yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '')
     if not yes: return
     from ptw.libraries import cache
     cache.cache_clear_all()
     control.infoDialog(control.lang(32057).encode('utf-8'), sound=True, icon='INFO')
Exemple #4
0
def addDownload(name, url, image, provider=None):
    try:

        def download():
            return []

        result = cache.bennu_download_get(download, 600000000, table='rel_dl')
        result = [i['name'] for i in result]
    except:
        pass

    try:
        if name in result:
            return control.infoDialog('Item Already In Your Queue', name)
    except:
        pass

    from resources.lib.indexers import bennustreams
    url = bennustreams.resolver().link(url)
    if url == None: return

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

        ext = os.path.splitext(urlparse.urlparse(u).path)[1][1:].lower()
        if ext == 'm3u8': raise Exception()
        if not ext in ['mp4', 'm4a', 'mp3', 'aac', 'mkv', 'flv', 'avi', 'mpg']:
            ext = 'mp4'
        dest = name + '.' + ext

        req = urllib2.Request(u, headers=headers)
        resp = urllib2.urlopen(req, timeout=30)
        size = int(resp.headers['Content-Length'])
        size = ' %.2f GB' % (float(size) / 1073741824)

        no = control.yesnoDialog(dest, 'Complete file is' + size,
                                 'Continue with download?',
                                 name + ' - ' + 'Confirm Download', 'Confirm',
                                 'Cancel')

        if no: return
    except:
        return control.infoDialog('Unable to download')
        pass

    def download():
        return [{'name': name, 'url': url, 'image': image}]

    result = cache.bennu_download_get(download, 600000000, table='rel_dl')
    result = [i for i in result if not i['url'] == url]

    def download():
        return result + [{'name': name, 'url': url, 'image': image}]

    result = cache.bennu_download_get(download, 0, table='rel_dl')

    control.infoDialog('Item Added to Queue', name)
Exemple #5
0
def authTrakt():
    try:
        if getTraktCredentialsInfo() == True:
            if control.yesnoDialog(
                    control.lang(32511).encode('utf-8'),
                    control.lang(32512).encode('utf-8'), '', 'Trakt'):
                control.setSetting(id='trakt.user', value='')
                control.setSetting(id='trakt.token', value='')
                control.setSetting(id='trakt.refresh', value='')
            raise Exception()

        result = getTraktAsJson('/oauth/device/code',
                                {'client_id': V2_API_KEY})
        verification_url = (control.lang(32513) %
                            result['verification_url']).encode('utf-8')
        user_code = (control.lang(32514) % result['user_code']).encode('utf-8')
        expires_in = int(result['expires_in'])
        device_code = result['device_code']
        interval = result['interval']

        progressDialog = control.progressDialog
        progressDialog.create('Trakt', verification_url, user_code)

        for i in range(0, expires_in):
            try:
                if progressDialog.iscanceled(): break
                time.sleep(1)
                if not float(i) % interval == 0: raise Exception()
                r = getTraktAsJson(
                    '/oauth/device/token', {
                        'client_id': V2_API_KEY,
                        'client_secret': CLIENT_SECRET,
                        'code': device_code
                    })
                if 'access_token' in r: break
            except:
                pass

        try:
            progressDialog.close()
        except:
            pass

        token, refresh = r['access_token'], r['refresh_token']

        headers = {
            'Content-Type': 'application/json',
            'trakt-api-key': V2_API_KEY,
            'trakt-api-version': 2,
            'Authorization': 'Bearer %s' % token
        }

        result = client.request(urlparse.urljoin(BASE_URL, '/users/me'),
                                headers=headers)
        result = utils.json_loads_as_str(result)

        user = result['username']

        control.setSetting(id='trakt.user', value=user)
        control.setSetting(id='trakt.token', value=token)
        control.setSetting(id='trakt.refresh', value=refresh)
        raise Exception()
    except:
        control.openSettings('3.1')