コード例 #1
0
ファイル: episodes.py プロジェクト: nadzvee/ProjectSwan
    def get(self,
            tvshowtitle,
            year,
            imdb,
            tvdb,
            season=None,
            episode=None,
            idx=True,
            provider=None,
            url=None):
        try:
            if idx == True:
                if not provider == None:
                    call = __import__('resources.lib.sources.%s' % provider,
                                      globals(), locals(), ['source'],
                                      -1).source()
                    self.list = call.episodes(tvshowtitle, url)
                    if self.list == []:
                        raise Exception(control.lang(30516).encode('utf-8'))
                    self.list = self.super_info(self.list)

                try:
                    logger.debug('Before Episode Direcotry', __name__)
                    self.episodeDirectory(self.list, provider)
                    logger.debug('After Episode Direcotry', __name__)
                except Exception as e:
                    logger.error(e)

                return self.list
        except Exception as e:
            logger.error(e)
            control.infoDialog(control.lang(30516).encode('utf-8'))
            pass
コード例 #2
0
    def addItem(self, title, content):
        try:
            control.playlist.clear()

            items = control.window.getProperty(self.itemProperty)
            items = json.loads(items)

            if items == []: raise Exception()

            meta = control.window.getProperty(self.metaProperty)
            meta = json.loads(meta)

            infoMenu = control.lang(30502).encode('utf-8')

            downloads = True if control.setting(
                'downloads') == 'true' and not control.setting(
                    'movie.download.path') == '' else False

            #if 'tvshowtitle' in meta and 'season' in meta and 'episode' in meta:
            #    name = '%s S%02dE%02d' % (title, int(meta['season']), int(meta['episode']))
            #el
            if 'year' in meta:
                name = '%s (%s)' % (title, meta['year'])
            else:
                name = title

            systitle = urllib.quote_plus(title.encode('utf-8'))

            sysname = urllib.quote_plus(name.encode('utf-8'))

            poster = meta['poster'] if 'poster' in meta else '0'
            banner = meta['banner'] if 'banner' in meta else '0'
            thumb = meta['thumb'] if 'thumb' in meta else poster
            fanart = meta['fanart'] if 'fanart' in meta else '0'

            if poster == '0': poster = control.addonPoster()
            if banner == '0' and poster == '0': banner = control.addonBanner()
            elif banner == '0': banner = poster
            if thumb == '0' and fanart == '0': thumb = control.addonFanart()
            elif thumb == '0': thumb = fanart
            if control.setting('fanart') == 'true' and not fanart == '0': pass
            else: fanart = control.addonFanart()

            for i in range(len(items)):
                try:
                    parts = int(items[i]['parts'])
                except:
                    parts = 1

                label = items[i]['label']

                syssource = urllib.quote_plus(json.dumps([items[i]]))

                sysurl = '%s?action=playItem&title=%s&source=%s&content=%s' % (
                    sysaddon, systitle, syssource, content)

                item = control.item(label=label)

                cm = []
                cm.append((control.lang(30504).encode('utf-8'),
                           'RunPlugin(%s?action=queueItem)' % sysaddon))
                if content != 'live':
                    if downloads == True and parts <= 1:
                        sysimage = urllib.quote_plus(poster.encode('utf-8'))
                        cm.append((control.lang(30505).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)'
                                   %
                                   (sysaddon, systitle, sysimage, syssource)))
                item.setArt({
                    'icon': thumb,
                    'thumb': thumb,
                    'poster': poster,
                    'tvshow.poster': poster,
                    'season.poster': poster,
                    'banner': banner,
                    'tvshow.banner': banner,
                    'season.banner': banner
                })

                if not fanart == None: item.setProperty('Fanart_Image', fanart)

                item.addContextMenuItems(cm)
                item.setInfo(type='Video', infoLabels=meta)

                control.addItem(handle=syshandle,
                                url=sysurl,
                                listitem=item,
                                isFolder=False)

            control.directory(syshandle, cacheToDisc=True)
        except Exception as e:
            logger.error(e.message)
            control.infoDialog(control.lang(30501).encode('utf-8'))
コード例 #3
0
    def playItem(self, content, title, source):
        try:
            self.isRegistered()
            control.resolve(syshandle, True, control.item(path=''))
            control.execute('Dialog.Close(okdialog)')

            next = []
            prev = []
            total = []
            meta = control.window.getProperty(self.metaProperty)
            #meta = self.metaProperty
            meta = json.loads(meta)

            year = meta['year'] if 'year' in meta else None
            imdb = meta['imdb'] if 'imdb' in meta else None
            tvdb = meta['tvdb'] if 'tvdb' in meta else None

            for i in range(1, 10000):
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))

                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?', '')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    next.append(u)
                except:
                    break
            for i in range(-10000, 0)[::-1]:
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?', '')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    prev.append(u)
                except:
                    break

            items = json.loads(source)
            items = [i for i in items + next + prev][:40]

            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0)

            block = None

            for i in range(len(items)):
                try:
                    self.progressDialog.update(
                        int((100 / float(len(items))) * i),
                        str(items[i]['label']), str(' '))

                    if items[i]['source'] == block: raise Exception()

                    w = workers.Thread(self.sourcesResolve, items[i])
                    w.start()

                    m = ''

                    for x in range(3600):
                        if self.progressDialog.iscanceled():
                            return self.progressDialog.close()
                        if xbmc.abortRequested == True: return sys.exit()
                        k = control.condVisibility(
                            'Window.IsActive(virtualkeyboard)')
                        if k:
                            m += '1'
                            m = m[-1]
                        if (w.is_alive() == False or x > 30) and not k: break
                        time.sleep(1.0)

                    for x in range(3600):
                        if m == '': break
                        if self.progressDialog.iscanceled():
                            return self.progressDialog.close()
                        if xbmc.abortRequested == True: return sys.exit()
                        if w.is_alive() == False: break
                        time.sleep(1.0)

                    if w.is_alive() == True: block = items[i]['source']

                    if self.url == None: raise Exception()

                    try:
                        self.progressDialog.close()
                    except:
                        pass

                    control.sleep(200)

                    if control.setting('playback_info') == 'true':
                        control.infoDialog(items[i]['label'])

                    player().run(content, title, self.url, year, imdb, tvdb,
                                 meta)

                    return self.url
                except Exception as e:
                    logger.error(e, __name__)
                    pass

            try:
                self.progressDialog.close()
            except:
                pass

            raise Exception()

        except Exception as e:
            logger.error(e.message)
            control.infoDialog(control.lang(30501).encode('utf-8'))
            pass
コード例 #4
0
    def play(self,
             name,
             title,
             year,
             imdb,
             tvdb,
             season,
             episode,
             tvshowtitle,
             date,
             meta,
             url,
             select=None):
        try:
            if not control.infoLabel('Container.FolderPath').startswith(
                    'plugin://'):
                control.playlist.clear()

            control.resolve(syshandle, True, control.item(path=''))
            control.execute('Dialog.Close(okdialog)')

            if imdb == '0': imdb = '0000000'
            imdb = 'tt' + re.sub('[^0-9]', '', str(imdb))

            content = 'movie' if tvshowtitle == None else 'episode'

            self.srcs = self.getSources(name, title, year, imdb, tvdb, season,
                                        episode, tvshowtitle, date, meta)

            items = self.sourcesFilter()

            if len(items) > 0:
                try:
                    select = control.setting(
                        'host_select') if select == None else select
                except:
                    pass

                if select == '1' and 'plugin' in control.infoLabel(
                        'Container.PluginName'):
                    logger.debug('INSIDE select=1', __name__)
                    control.window.clearProperty(self.itemProperty)
                    control.window.setProperty(self.itemProperty,
                                               json.dumps(items))

                    control.window.clearProperty(self.metaProperty)
                    control.window.setProperty(self.metaProperty, meta)

                    control.sleep(200)
                    return control.execute(
                        'Container.Update(%s?action=addItem&title=%s&content=%s)'
                        % (sysaddon, urllib.quote_plus(
                            title.encode('utf-8')), content))

                elif select == '0' or select == '1':
                    url = self.sourcesDialog(items)

                else:
                    url = self.sourcesDirect(items)

            if url == None: raise Exception()
            if url == 'close://': return

            if control.setting('playback_info') == 'true':
                control.infoDialog(self.selectedSource, heading=name)

            control.sleep(200)

            player().run(content, name, url, year, imdb, tvdb, meta)

            return url
        except Exception as e:
            logger.error(e.message)
            control.infoDialog(control.lang(30501).encode('utf-8'))
コード例 #5
0
    def movieDirectory(self, items, lang=None):
        if items == None or len(items) == 0:
            control.infoDialog(control.lang(30518).encode('utf-8'))
            return

        indicators = playcount.getMovieIndicators()

        isPlayable = 'true' if not 'plugin' in control.infoLabel(
            'Container.PluginName') else 'false'

        playbackMenu = control.lang(30204).encode('utf-8') if control.setting(
            'host_select') == '2' else control.lang(30203).encode('utf-8')

        cacheToDisc = False if not action == 'movieSearch' else True

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting(
            'fanart')

        for i in items:
            try:
                label = '%s (%s)' % (i['title'], i['year'])
                imdb, title, year, trailer = i['imdb'], i['title'], i[
                    'year'], i.get('trailer')
                sysname = urllib.quote_plus('%s (%s)' % (title, year))
                systitle = urllib.quote_plus(title)

                poster, banner, fanart = i['poster'], i['banner'], i['fanart']
                if poster == '0': poster = addonPoster
                if banner == '0' and poster == '0': banner = addonBanner
                elif banner == '0': banner = poster

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s&url=%s' %
                    (sysaddon, sysname, trailer)
                })
                if i['duration'] == '0': meta.update({'duration': '120'})
                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass
                sysmeta = urllib.quote_plus(json.dumps(meta))

                url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (
                    sysaddon, sysname, systitle, year, imdb, sysmeta,
                    self.systime)
                sysurl = urllib.quote_plus(url)

                cm = []

                cm.append((playbackMenu,
                           'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' %
                           (sysaddon, sysurl, sysmeta)))  # AUTOPLAY

                cm.append((control.lang(30214).encode('utf-8'),
                           'RunPlugin(%s?action=trailer&name=%s&url=%s)' %
                           (sysaddon, sysname, trailer)))  # TRAILER
                cm.append((control.lang(30205).encode('utf-8'),
                           'Action(Info)'))  # MOVIEINFORMATION

                cm.append((control.lang(30212).encode('utf-8'),
                           'RunPlugin(%s?action=addView&content=movies)' %
                           sysaddon))  # SET MOVIES VIEW

                try:
                    overlay = int(playcount.getMovieOverlay(indicators, imdb))
                    #logger.debug('imdb : %s Overlay : %s' % (imdb, overlay), __name__)
                    if overlay == 7:
                        cm.append((control.lang(30206).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)'
                                   % (sysaddon, imdb)))
                        meta.update({'playcount': 1, 'overlay': 7})
                    else:
                        cm.append((control.lang(30207).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)'
                                   % (sysaddon, imdb)))
                        meta.update({'playcount': 0, 'overlay': 6})
                except Exception as e:
                    logger.error(e, __name__)
                    pass

                item = control.item(label=label,
                                    iconImage=poster,
                                    thumbnailImage=poster)

                try:
                    item.setArt({'poster': poster, 'banner': banner})
                except:
                    pass

                if settingFanart == 'true' and not fanart == '0':
                    item.setProperty('Fanart_Image', fanart)
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setInfo(type='Video', infoLabels=meta)
                item.setProperty('Video', 'true')
                item.setProperty('IsPlayable', isPlayable)
                item.addContextMenuItems(cm)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=False)
            except Exception as e:
                logger.error(e, __name__)
                pass
        try:
            url = items[0]['next']
            if url == '': raise Exception()
            url = '%s?action=movies&url=%s' % (sysaddon,
                                               urllib.quote_plus(url))
            addonNext = control.addonNext()
            item = control.item(label=control.lang(30213).encode('utf-8'),
                                iconImage=addonNext,
                                thumbnailImage=addonNext)
            item.addContextMenuItems([])
            if not addonFanart == None:
                item.setProperty('Fanart_Image', addonFanart)
            control.addItem(handle=syshandle,
                            url=url,
                            listitem=item,
                            isFolder=True)
        except Exception as e:
            logger.error(e, __name__)
            pass

        content = 'movies'
        control.content(syshandle, content)
        control.directory(syshandle, cacheToDisc=cacheToDisc)
        views.setView(
            content, {
                'skin.confluence':
                control.viewMode['confluence']['thumbnails'],
                'skin.estuary': control.viewMode['esturary']['list']
            })