Пример #1
0
    def listBollywood(self, url, page):
        try: html = client.request(url + 'page/' + str(page))
        except: pass

        syshandle = int(sys.argv[1])

        result = client.parseDOM(html, 'article', attrs={'id': 'posts'})
        result = [(client.parseDOM(i, 'a', ret='href'), client.parseDOM(i, 'img', ret='src'), client.parseDOM(i, 'a')) for i in result]
        result = [(i[0][0], i[1][0], i[2][1]) for i in result if len(i[0]) > 0 and len(i[1]) > 0 and len(i[2][1]) > 0]

        for movie in result:
            uri = movie[0]
            image = movie[1]
            name = movie[2]
            action = 'resolveBollywoodUrl'
            query = '%s?action=%s&name=%s&url=%s&image=%s' % (sysaddon, action, name, uri, image)
            item = control.item(name, iconImage=image, thumbnailImage=image)
            item.setInfo(type="Video", infoLabels={"Title": name, "OriginalTitle": name})
            control.addItem(handle=int(sys.argv[1]), url=query, listitem=item, isFolder=True)

        pageNum = int(page)+1
        query = '%s?action=%s&url=%s&page=%s' % (sysaddon, 'listBollywood', url, pageNum)

        item = control.item('Next page', iconImage='', thumbnailImage='')
        item.setInfo(type="Video", infoLabels={"Title": 'Page ' + str(page), "OriginalTitle": 'Page ' + str(page)})
        control.addItem(handle=syshandle, url=query, listitem=item, isFolder=True)

        control.content(syshandle, 'movies')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('movies', {'skin.estuary': 500, 'skin.confluence': 500})
Пример #2
0
def playItem(url, dialog=None):
    try:
        url = resolveUrl(url)

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

        meta = {}
        for i in ['title', 'originaltitle', 'tvshowtitle', 'year', 'season', 'episode', 'genre', 'rating', 'votes', 'director', 'writer', 'plot', 'tagline']:
            try: meta[i] = control.infoLabel('listitem.%s' % i)
            except: pass
        meta['title'] = cleantitle(meta['title'])
        meta = dict((k,v) for k, v in meta.iteritems() if not v == '')
        if not 'title' in meta: meta['title'] = cleantitle(control.infoLabel('listitem.label'))
        icon = control.infoLabel('listitem.icon')
        title = meta['title']

        try:
            if not '.f4m'in url: raise Exception()
            ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower()
            if not ext == 'f4m': raise Exception()
            from resources.lib.modules.f4mproxy.F4mProxy import f4mProxyHelper
            return f4mProxyHelper().playF4mLink(url, title, None, None, '', icon)
        except:
            pass

        item = control.item(path=url, iconImage=icon, thumbnailImage=icon)
        try: item.setArt({'icon': icon})
        except: pass
        item.setInfo(type='Video', infoLabels = meta)
        control.player.play(url, item)
    except:
        pass
Пример #3
0
    def addDirectory(self, items):
        if items == None or len(items) == 0: return

        sysaddon = sys.argv[0]
        addonFanart, addonThumb, artPath = control.addonFanart(), control.addonThumb(), control.artPath()

        for i in items:
            try:
                try: name = control.lang(i['name']).encode('utf-8')
                except: name = i['name']

                if i['image'].startswith('http://'): thumb = i['image']
                elif not artPath == None: thumb = os.path.join(artPath, i['image'])
                else: thumb = addonThumb

                url = '%s?action=%s' % (sysaddon, i['action'])
                try: url += '&url=%s' % urllib.quote_plus(i['url'])
                except: pass

                cm = []

                item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb)
                item.addContextMenuItems(cm, replaceItems=False)
                if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
            except:
                pass

        control.directory(int(sys.argv[1]), cacheToDisc=True)
    def addPlaylistItem(self, name, playlist_id, icon, fanart):
        work_url = "plugin://plugin.video.youtube/playlist/"+playlist_id+"/"
        liz=control.item(name)
        liz.setInfo( type="Video", infoLabels={ "Title": name })
        liz.setArt({ 'thumb': icon, 'banner' : 'DefaultVideo.png', 'fanart': fanart })
#        liz.setPath(work_url)
        control.addItem(handle=syshandle,url=work_url,listitem=liz,isFolder=True)
Пример #5
0
 def play(self, name, image, uri):
     try:
         from resources.lib.modules.player import player
         item = control.item(label=name, iconImage=image, thumbnailImage=image)
         player().play(uri, item)
     except:
         pass
Пример #6
0
def addCategoryItem(name, action, image, isFolder=True):
    u = '%s?action=%s' % (sys.argv[0], str(action))
    image = control.addonInfo('path') + '/resources/media/LwSLive/' + image
    item = control.item(name, iconImage=image, thumbnailImage=image)
    item.addContextMenuItems([], replaceItems=False)
    item.setProperty('Fanart_Image', control.addonInfo('fanart'))
    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=isFolder)
Пример #7
0
def add_last_visited(anime_id):
    try:
        c = cache.get(masterani.get_anime_details, 8, anime_id)
        
        lastEpisode = watched.Watched().watched(anime_id)
        
        plot = c['plot']
        premiered = c['premiered']
        genre = c['genre']
        
        type = c['type']

        sysaddon = sys.argv[0]
        addon_poster = addon_banner = control.addonInfo('icon')
        addon_fanart = control.addonInfo('fanart')

        item = control.item("Last Played: [I]%s[/I]" % (c['title']))

        poster = "http://cdn.masterani.me/poster/%s" % c['poster']
        fanart = "http://cdn.masterani.me/wallpaper/0/%s" % c['fanart'][0]
        item.setArt({'poster': poster})
        item.setProperty("Fanart_Image", fanart)
        item.setInfo(type='Video', infoLabels={
            'Plot': plot, 'Year': premiered, 'premiered': premiered,
            'genre': genre, 'mediatype': 'tvshow' 
        })

        url = '%s?action=get_episodes' % sysaddon
        try: url += '&anime_id=%s' % anime_id
        except: pass

        control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
    except:
        pass
Пример #8
0
    def views(self):
        try:
            control.idle()

            items = [ (control.lang(32001).encode('utf-8'), 'movies'), (control.lang(32002).encode('utf-8'), 'tvshows'), (control.lang(32054).encode('utf-8'), 'seasons'), (control.lang(32038).encode('utf-8'), 'episodes') ]

            select = control.selectDialog([i[0] for i in items], control.lang(32049).encode('utf-8'))

            if select == -1: return

            content = items[select][1]

            title = control.lang(32059).encode('utf-8')
            url = '%s?action=addView&content=%s' % (sys.argv[0], content)

            poster, banner, fanart = control.addonPoster(), control.addonBanner(), control.addonFanart()

            item = control.item(label=title)
            item.setInfo(type='Video', infoLabels = {'title': title})
            item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner})
            item.setProperty('Fanart_Image', fanart)

            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False)
            control.content(int(sys.argv[1]), content)
            control.directory(int(sys.argv[1]), cacheToDisc=True)

            from resources.lib.modules import cache
            views.setView(content, {})
        except:
            return
Пример #9
0
    def play(self, name, url=None, windowedtrailer=0):
        try:
            url = self.worker(name, url)
            if not url: return

            title = control.infoLabel('listitem.title')
            if not title: title = control.infoLabel('listitem.label')
            icon = control.infoLabel('listitem.icon')

            item = control.item(path=url, iconImage=icon, thumbnailImage=icon)
            try: item.setArt({'icon': icon})
            except: pass
            item.setInfo(type='Video', infoLabels={'title': title})
            control.player.play(url, item, windowedtrailer)
            if windowedtrailer == 1:
                # The call to the play() method is non-blocking. So we delay further script execution to keep the script alive at this spot.
                # Otherwise this script will continue and probably already be garbage collected by the time the trailer has ended.
                control.sleep(1000)  # Wait until playback starts. Less than 900ms is too short (on my box). Make it one second.
                while control.player.isPlayingVideo():
                    control.sleep(1000)
                # Close the dialog.
                # Same behaviour as the fullscreenvideo window when :
                # the media plays to the end,
                # or the user pressed one of X, ESC, or Backspace keys on the keyboard/remote to stop playback.
                control.execute("Dialog.Close(%s, true)" % control.getCurrentDialogId)      
        except:
            pass
Пример #10
0
    def addDirectoryItem(self, name, query, thumb, icon, queue=False, isAction=True, isFolder=True, imgPath = None):

        self.logger = logging.getLogger('funimationnow');

        try: 

            name = control.lang(name).encode('utf-8') if isinstance(name, (int, long)) else name;

        except: 
            pass;

        url = '%s?action=%s' % (sysaddon, query) if isAction == True else query;

        artPath = control.artPath(imgPath);
        thumb = os.path.join(artPath, thumb) if not artPath == None else icon;

        cm = [];

        if queue == True: 
            cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon));

        item = control.item(label=name);

        item.addContextMenuItems(cm);
        item.setArt({'icon': thumb, 'thumb': thumb});

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

        control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder);
Пример #11
0
    def addDirectory(self, items, queue=False):
        if items == None or len(items) == 0: return

        sysaddon = sys.argv[0]
        isPlayable = False if control.setting('autoplay') == 'false' and control.setting('hosts.mode') == '1' else True
        addonFanart, addonThumb, artPath = control.addonFanart(), control.addonThumb(), control.artPath()

        for i in items:
            try:
                try: name = control.lang(i['name']).encode('utf-8')
                except: name = i['name']

                if i['image'].startswith('http://'): thumb = i['image']
                elif not artPath == None: thumb = os.path.join(artPath, i['image'])
                else: thumb = addonThumb

                url = '%s?action=%s' % (sysaddon, i['action'])
                try: url += '&url=%s' % urllib.quote_plus(i['url'])
                except: pass

                cm = []

                if queue == True and isPlayable == True:
                    cm.append((control.lang(30202).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon))

                item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb)
                item.addContextMenuItems(cm, replaceItems=False)
                if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
            except:
                pass

        control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #12
0
def addDirectoryItem(name, action, thumb, image, fanart, url='0'):
    if thumb == '0': thumb = image
    u = '%s?action=%s&url=%s&image=%s&fanart=%s' % (sys.argv[0], str(action), urllib.quote_plus(url), urllib.quote_plus(thumb), urllib.quote_plus(fanart))
    item = control.item(name, iconImage=thumb, thumbnailImage=thumb)
    item.addContextMenuItems([], replaceItems=False)
    item.setProperty('Fanart_Image', fanart)
    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=True)
Пример #13
0
    def channelDirectory(self, items):
        if items == None or len(items) == 0: return

        playbackMenu = control.lang(30292).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30291).encode('utf-8')

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart = control.addonFanart()
        sysaddon = sys.argv[0]


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

                poster, banner = i['poster'], i['poster']
                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' % (sysaddon, sysname)})
                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&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (sysaddon, 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)))
                cm.append((control.lang(30297).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname)))
                cm.append((control.lang(30293).encode('utf-8'), 'Action(Info)'))
                cm.append((control.lang(30294).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % (sysaddon)))
                cm.append((control.lang(30295).encode('utf-8'), 'RunPlugin(%s?action=openSettings)' % (sysaddon)))
                cm.append((control.lang(30296).encode('utf-8'), 'RunPlugin(%s?action=openPlaylist)' % (sysaddon)))

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

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

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

                item.setInfo(type='Video', infoLabels = meta)
                item.setProperty('Video', 'true')
                #item.setProperty('IsPlayable', 'true')
                item.addContextMenuItems(cm, replaceItems=True)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False)
            except:
                pass

        control.content(int(sys.argv[1]), 'movies')
        #control.do_block_check(False)
        control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #14
0
def addCategoryItem(name, action, image, fanart, url='0'):
    u = '%s?action=%s&url=%s&image=%s&fanart=%s' % (sys.argv[0], str(action), urllib.quote_plus(url), urllib.quote_plus(image), urllib.quote_plus(fanart))
    item = control.item(name, iconImage=image, thumbnailImage=image)
    try: item.setArt({'icon': image})
    except: pass
    item.addContextMenuItems([], replaceItems=False)
    item.setProperty('Fanart_Image', fanart)
    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=True)
Пример #15
0
    def addVideoItem(self, name, video_id, icon, fanart):
        work_url = "plugin://plugin.video.youtube/play/?video_id="+video_id
        liz=control.item(name)
        liz.setInfo( type="Video", infoLabels={ "Title": name })
        liz.setArt({ 'thumb': icon, 'banner' : 'DefaultVideo.png', 'fanart': fanart })
#        liz.setPath(work_url)
        liz.setProperty('IsPlayable', 'true')
        control.addItem(handle=syshandle,url=work_url,listitem=liz,isFolder=True)
Пример #16
0
def radioResolve(name, url, image):
    url = radio1fmResolve(url)
    meta = {'title': name, 'album': name, 'artist': name, 'comment': name}
    item = control.item(path=url, iconImage=image, thumbnailImage=image)
    try: item.setArt({'icon': image})
    except: pass
    item.setInfo(type='Music', infoLabels = meta)
    control.player.play(url, item)
Пример #17
0
def downloader():

    thumb = control.addonThumb() ; fanart = control.addonFanart()

    status = control.window.getProperty(property + '.status')

    if not downloadPath == '':
        item = control.item('[COLOR FF00b8ff]Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]), url=downloadPath, listitem=item, isFolder=True)

    if status == 'downloading':
        item = control.item('[COLOR red]Stop Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]), url=sys.argv[0]+'?action=stopDownload', listitem=item, isFolder=True)
    else:
        item = control.item('[COLOR FF00b8ff]Start Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]), url=sys.argv[0]+'?action=startDownload', listitem=item, isFolder=True)

    if status == 'downloading':
        item = control.item('[COLOR gold]Download Status[/COLOR]', iconImage=thumb, thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('Fanart_Image', fanart)
        control.addItem(handle=int(sys.argv[1]), url=sys.argv[0]+'?action=statusDownload', listitem=item, isFolder=True)

    def download(): return []
    result = cache.neptune_download_get(download, 600000000, table='rel_dl')

    for i in result:
        try:
            cm = []
            cm.append(('Remove from Queue', 'RunPlugin(%s?action=removeDownload&url=%s)' % (sys.argv[0], urllib.quote_plus(i['url']))))
            item = control.item(i['name'], iconImage=i['image'], thumbnailImage=i['image'])
            item.addContextMenuItems(cm, replaceItems=True)
            item.setProperty('fanart_image', fanart)
            item.setProperty('Video', 'true')
            item.setProperty('IsPlayable', 'true')
            control.addItem(handle=int(sys.argv[1]), url=i['url'], listitem=item)
        except:
            pass

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #18
0
def addCategoryItem(name, action, image, isFolder=True):
    u = '%s?action=%s' % (sys.argv[0], str(action))
    item = control.item(name, iconImage=image, thumbnailImage=image)
    try: item.setArt({'icon': image})
    except: pass
    item.addContextMenuItems([], replaceItems=False)
    item.setProperty('Fanart_Image', control.addonInfo('fanart'))
    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=isFolder)
Пример #19
0
    def addDir(self, name, info, u, action, image, isFolder=True):
        url = (sysaddon + "?url=" + urllib.quote_plus(u) + "&name=" + urllib.quote_plus(name.encode('utf-8')) + "&action=" + action + "&image=" + image)

        item = control.item(label=name.encode('utf-8'))
        item.setArt({'icon': image, 'thumb': image})
        item.setInfo(type="Video", infoLabels={"Title": name.encode('utf-8'), "OriginalTitle": name.encode('utf-8'), "Plot": info})

        control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder)
Пример #20
0
def addDirectoryItem(name, url, action, image, image2, fanart, content, data, tvshow='0', totalItems=0, isFolder=True):
    if not str(image).lower().startswith('http'): image = control.addonInfo('icon')

    if not str(image2).lower().startswith('http'): image2 = control.addonInfo('icon')

    if not str(fanart).lower().startswith('http'): fanart = control.addonInfo('fanart')

    if content in ['movies', 'episodes']: playable = 'true'
    else: playable = 'false'

    sysaddon = sys.argv[0]

    if url.startswith('$base64'):
        import base64 ; url = base64.b64decode(re.compile('\$base64\[(.+?)\]$').findall(url)[0])
    u = '%s?name=%s&url=%s&tvdb=&imdb=&source=GVideo&provider=Mpie&content=%s&action=playItem' % (sysaddon, urllib.quote_plus(name), urllib.quote_plus(url), str(content))

    cm = []

    if content == 'movies':
        cm.append((control.lang(30708).encode('utf-8'), 'XBMC.Action(Info)'))
    elif content in ['tvshows', 'seasons']:
        cm.append((control.lang(30709).encode('utf-8'), 'XBMC.Action(Info)'))
    elif content == 'episodes':
        cm.append((control.lang(30710).encode('utf-8'), 'XBMC.Action(Info)'))


    if content == 'movies' and not isFolder == True:
        downloadFile = name
        try: downloadFile = '%s (%s)' % (data['title'], data['year'])
        except: pass
        cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image))))

    elif content == 'episodes' and not isFolder == True:
        downloadFile = name
        try: downloadFile = '%s S%02dE%02d' % (data['tvshowtitle'], int(data['season']), int(data['episode']))
        except: pass
        cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image))))


    if content == 'movies':
        cm.append((control.lang(30711).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon))
    elif content == 'tvshows':
        cm.append((control.lang(30712).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon))
    elif content == 'seasons':
        cm.append((control.lang(30713).encode('utf-8'), 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon))
    elif content == 'episodes':
        cm.append((control.lang(30714).encode('utf-8'), 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon))


    item = control.item(name, iconImage='DefaultFolder.png', thumbnailImage=image)
    try: item.setArt({'poster': image2, 'tvshow.poster': image2, 'season.poster': image2, 'banner': image, 'tvshow.banner': image, 'season.banner': image})
    except: pass
    item.addContextMenuItems(cm, replaceItems=False)
    item.setProperty('Fanart_Image', fanart)
    if playable == 'true': item.setProperty('IsPlayable', 'true')
    item.setInfo(type='Video', infoLabels=data)

    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,totalItems=totalItems,isFolder=isFolder)
Пример #21
0
 def addDirectoryItem(self, name, query, thumb, icon, isAction=True):
     try:
         name = name.encode('utf-8')
         url = '%s?action=%s' % (sysaddon, query) if isAction == True else query
         item = control.item(label=name)
         item.setArt({'icon': thumb, 'thumb': thumb})
         control.addItem(handle=syshandle, url=url, listitem=item)
     except:
         pass
Пример #22
0
    def play(self, url, content=None):
        try:
            base = url

            url = resolver().get(url)
            if url == False: return

            control.execute('ActivateWindow(busydialog)')
            url = resolver().process(url)
            control.execute('Dialog.Close(busydialog)')

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

            meta = {}
            for i in ['title', 'originaltitle', 'tvshowtitle', 'year', 'season', 'episode', 'genre', 'rating', 'votes', 'director', 'writer', 'plot', 'tagline']:
                try: meta[i] = control.infoLabel('listitem.%s' % i)
                except: pass
            meta = dict((k,v) for k, v in meta.iteritems() if not v == '')
            if not 'title' in meta: meta['title'] = control.infoLabel('listitem.label')
            icon = control.infoLabel('listitem.icon')


            self.name = meta['title'] ; self.year = meta['year'] if 'year' in meta else '0'

            self.getbookmark = True if (content == 'movies' or content == 'episodes') else False

            self.offset = bookmarks().get(self.name, self.year)

            if not 'tvplayer' in url:
				if not 'itv' in url:
						f4m = resolver().f4m(url, self.name)
						if not f4m == None: return


            item = control.item(path=url, iconImage=icon, thumbnailImage=icon)
            try: item.setArt({'icon': icon})
            except: pass
            item.setInfo(type='Video', infoLabels = meta)
            control.player.play(url, item)
            control.resolve(int(sys.argv[1]), True, item)

            self.totalTime = 0 ; self.currentTime = 0

            for i in range(0, 240):
                if self.isPlayingVideo(): break
                control.sleep(1000)
            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()
                except:
                    pass
                control.sleep(2000)
            control.sleep(5000)
        except:
            pass
Пример #23
0
    def run(self, anime_id, ep_id, url):
        control.sleep(200)

        self.anime_id = int(anime_id)
        self.episode_id = int(ep_id)

        item = control.item(path=url)

        try:
            c = cache.get(masterani.get_anime_details, 3, self.anime_id)

            ctype = c['type']
            ctype = 'video' if int(ctype) is 2 else 'episode'

            tvshowtitle = c['title']
            poster = c['poster']
            print poster
            genre = c['genre']
            print genre
			
            coverlink = "http://cdn.masterani.me/poster/" + poster
            print coverlink

            item.setArt({'icon': coverlink, 'thumb': coverlink, 'poster': coverlink, 'tvshow.poster': coverlink, 'season.poster': coverlink})

            e = c['episodes'][self.episode_id]
            title = e['info']['title']
            season = 1
            if season is None: season = 1
            episode = e['info']['episode']
            if ctype is 'video': title = c['title']
            if title is None: title = "Episode %s" % episode
			
            year = e['info']['aired']
            year = year.split("-", 1)[0]
            print year

            plot = e['info']['description']
            print plot

            item.setInfo(type="video",
                         infoLabels={'tvshowtitle': title, 'title': tvshowtitle, 'episode': int(episode),
                                     'season': int(season), 'mediatype': ctype, 'genre': genre,
                                     'year': year, 'plot': plot})

        except:
            pass

        item.setProperty('Video', 'true')
        item.setProperty('IsPlayable', 'true')

        self.play(url, item)

        self.playback_checker()

        pass
Пример #24
0
def radioResolve(url):
    url = radio1fmResolve(url)
    url = client.request(url, output='geturl')
    title = control.infoLabel('ListItem.Label')
    image = control.infoLabel('ListItem.Icon')
    meta = {'title': title, 'album': title, 'artist': title, 'comment': title}
    item = control.item(path=url, iconImage=image, thumbnailImage=image)
    item.setArt({'icon': image})
    item.setInfo(type='Music', infoLabels = meta)
    control.player.play(url, item)
Пример #25
0
    def play(self, name, url=None):
        try:
            url = self.worker(name, url)
            if url == None: return

            item = control.item(path=url)
            item.setProperty('IsPlayable', 'true')
            control.player.play(url, item)
        except:
            pass
Пример #26
0
    def run(self, url):
        title = control.infoLabel('ListItem.Label')
        image = control.infoLabel('ListItem.Icon')
        item = control.item(path=url, iconImage=image, thumbnailImage=image)
        item.setInfo(type='Video', infoLabels = {'title': title})
        control.player.play(url, item)

        for i in range(0, 240):
            if self.isPlayingVideo(): break
            control.sleep(1000)
Пример #27
0
def resolveUrl(name, url, image, fanart, playable, content):
    try:
        if url.startswith('$base64'):
            import base64 ; url = base64.b64decode(re.compile('\$base64\[(.+?)\]$').findall(url)[0])
        label = cleantitle(name)
        item = control.item(path=url, iconImage=image, thumbnailImage=image)
        item.setInfo( type='Video', infoLabels = {'title': label} )
        control.playlist.clear()
        control.player.play(url, item)
    except:
        pass
Пример #28
0
 def addDirectoryItem(self, name, query, thumb, icon, queue=False, isAction=True, isFolder=True):
     try: name = control.lang(name).encode('utf-8')
     except: pass
     url = '%s?action=%s' % (sysaddon, query) if isAction == True else query
     cm = []
     if queue == True: cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))
     item = control.item(label=name)
     item.addContextMenuItems(cm)
     item.setArt({'icon': thumb, 'thumb': thumb})
     if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
     control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder)
Пример #29
0
 def addDirectoryItem(self, name, query, thumb, icon, queue=False, isAction=True, isFolder=True):
     try: name = control.lang(name).encode('utf-8')
     except: pass
     url = '%s?action=%s' % (sysaddon, query) if isAction == True else query
     thumb = os.path.join(artPath, thumb) if not artPath == None else icon
     cm = []
     if queue == True and isPlayable == True: cm.append((control.lang(30155).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon))
     item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb)
     item.addContextMenuItems(cm, replaceItems=False)
     if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
     control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder)
Пример #30
0
def addDirectoryItem(name, url, action, image, fanart, isFolder=True):
    if image == '0': image = addonIcon
    if fanart == '0': fanart = addonFanart

    u = '%s?name=%s&url=%s&image=%s&fanart=%s&action=%s' % (sys.argv[0], urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(image), urllib.quote_plus(fanart), str(action))

    item = control.item(name, iconImage=image, thumbnailImage=image)
    item.setInfo(type='Video', infoLabels = {'title': name})
    item.addContextMenuItems([], replaceItems=False)
    item.setProperty('Fanart_Image', fanart)
    if not isFolder == True: item.setProperty('IsPlayable', 'true')
    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=isFolder)
Пример #31
0
    def addDirectoryItem(self,
                         name,
                         query,
                         thumb,
                         icon,
                         context=None,
                         queue=False,
                         isAction=True,
                         isFolder=True):
        try:
            name = control.lang(name)
        except:
            pass

        sysaddon = sys.argv[0]
        syshandle = int(sys.argv[1])

        url = '%s?action=%s' % (sysaddon, query) if isAction is True else query
        thumb = control.joinPath(artPath,
                                 thumb) if artPath is not None else icon

        cm = []
        if queue:
            cm.append((queueMenu,
                       'RunPlugin(%s?action=playlist_QueueItem)' % sysaddon))
        if context:
            cm.append((control.lang(context[0]),
                       'RunPlugin(%s?action=%s)' % (sysaddon, context[1])))

        item = control.item(label=name)
        item.addContextMenuItems(cm)
        item.setArt({'icon': thumb, 'thumb': thumb, 'fanart': addonFanart})
        control.addItem(handle=syshandle,
                        url=url,
                        listitem=item,
                        isFolder=isFolder)
Пример #32
0
    def play(self, name='', url='', windowedtrailer=0):
        try:
            url = self.worker(name, url)
            if not url: return

            title = control.infoLabel('ListItem.Title')
            if not title: title = control.infoLabel('ListItem.Label')

            icon = control.infoLabel('ListItem.Icon')

            item = control.item(label=title,
                                iconImage=icon,
                                thumbnailImage=icon,
                                path=url)
            item.setInfo(type="video", infoLabels={'title': title})
            item.setProperty('IsPlayable', 'true')
            control.resolve(handle=int(sys.argv[1]),
                            succeeded=True,
                            listitem=item)
            if windowedtrailer == 1:
                # The call to the play() method is non-blocking. So we delay further script execution to keep the script alive at this spot.
                # Otherwise this script will continue and probably already be garbage collected by the time the trailer has ended.
                control.sleep(
                    1000
                )  # Wait until playback starts. Less than 900ms is too short (on my box). Make it one second.
                while control.player.isPlayingVideo():
                    control.sleep(1000)
                # Close the dialog.
                # Same behaviour as the fullscreenvideo window when :
                # the media plays to the end,
                # or the user pressed one of X, ESC, or Backspace keys on the keyboard/remote to stop playback.
                control.execute("Dialog.Close(%s, true)" %
                                control.getCurrentDialogId)
        except:
            import traceback
            traceback.print_exc()
Пример #33
0
 def views(self):
     try:
         control.hide()
         items = [(control.lang(32001), 'movies'),
                  (control.lang(32002), 'tvshows'),
                  (control.lang(32054), 'seasons'),
                  (control.lang(32038), 'episodes')]
         select = control.selectDialog([i[0] for i in items],
                                       control.lang(32049))
         if select == -1: return
         content = items[select][1]
         title = control.lang(32059)
         url = '%s?action=tools_addView&content=%s' % (sys.argv[0], content)
         poster, banner, fanart = control.addonPoster(
         ), control.addonBanner(), control.addonFanart()
         item = control.item(label=title)
         item.setInfo(type='video', infoLabels={'title': title})
         item.setArt({
             'icon': poster,
             'thumb': poster,
             'poster': poster,
             'fanart': fanart,
             'banner': banner
         })
         item.setProperty('IsPlayable', 'false')
         control.addItem(handle=int(sys.argv[1]),
                         url=url,
                         listitem=item,
                         isFolder=False)
         control.content(int(sys.argv[1]), content)
         control.directory(int(sys.argv[1]), cacheToDisc=True)
         from resources.lib.modules import views
         views.setView(content, {})
     except:
         log_utils.error()
         return
Пример #34
0
	def addDirectoryItem(self, name, query, thumb, icon, context=None, queue=False, isAction=True, isFolder=True, isPlayable=False, isSearch=False, table=''):
		sysaddon = sys.argv[0]
		syshandle = int(sys.argv[1])
		try:
			if type(name) is str or type(name) is unicode:
				name = str(name)
			if type(name) is int:
				name = control.lang(name)
		except:
			log_utils.error()

		url = '%s?action=%s' % (sysaddon, query) if isAction else query
		thumb = control.joinPath(artPath, thumb) if artPath else icon
		if not icon.startswith('Default'):
			icon = control.joinPath(artPath, icon)
		cm = []
		queueMenu = control.lang(32065)
		if queue:
			cm.append((queueMenu, 'RunPlugin(%s?action=playlist_QueueItem)' % sysaddon))
		if context:
			cm.append((control.lang(context[0]), 'RunPlugin(%s?action=%s)' % (sysaddon, context[1])))
		if isSearch:
			try:
				from urllib import quote_plus
			except:
				from urllib.parse import quote_plus
			cm.append(('Clear Search Phrase', 'RunPlugin(%s?action=cache_clearSearchPhrase&source=%s&name=%s)' % (sysaddon, table, quote_plus(name))))
		cm.append(('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=openSettings)' % sysaddon))
		item = control.item(label=name)
		item.addContextMenuItems(cm)
		if isPlayable:
			item.setProperty('IsPlayable', 'true')
		else:
			item.setProperty('IsPlayable', 'false')
		item.setArt({'icon': icon, 'poster': thumb, 'thumb': thumb, 'fanart': control.addonFanart(), 'banner': thumb})
		control.addItem(handle=syshandle, url=url, listitem=item, isFolder= isFolder)
Пример #35
0
    def channel_directory(self, items):
        if items is None or len(items) == 0: control.idle(); sys.exit()

        sysaddon = sys.argv[0]
        syshandle = int(sys.argv[1])
        fanart = os.path.join(artPath, 'fanart_sexyhot.png')
        logo = os.path.join(artPath, 'logo_sexyhot.png')

        refreshMenu = control.lang(32072).encode('utf-8')

        cm = []
        cm.append((refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon))

        for index, item in enumerate(items):
            label = item['name']
            sysurl = urllib.quote_plus(item['url'])

            url = '%s?action=getVideos&provider=sexyhot&url=%s' % (sysaddon, sysurl)

            item = control.item(label=label)

            item.setArt({
                'logo': logo,
                # 'thumb': logo,
                'fanart': fanart,
            })
            item.addContextMenuItems(cm)
            item.setProperty('IsPlayable', 'true')
            item.setProperty('Fanart_Image', fanart)
            item.setInfo(type='video', infoLabels={'title': label})
            control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)

        # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_LABEL_IGNORE_FOLDERS)

        control.content(syshandle, 'files')
        control.directory(syshandle, cacheToDisc=False)
Пример #36
0
    def tvshowDirectory(self, items):
        if items == None or len(items) == 0: return

        isFolder = True if control.setting(
            'autoplay') == 'false' and control.setting(
                'hosts.mode') == '1' else False
        isFolder = False if control.window.getProperty(
            'PseudoTVRunning') == 'True' else isFolder

        traktCredentials = trakt.getTraktCredentialsInfo()

        indicators = playcount.getTVShowIndicators()

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting(
            'fanart')
        sysaddon = sys.argv[0]

        for i in items:
            try:
                label = i['title']
                systitle = sysname = urllib.quote_plus(i['originaltitle'])
                sysimage = urllib.quote_plus(i['poster'])
                imdb, tvdb, year = i['imdb'], i['tvdb'], i['year']

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

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

                url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (
                    sysaddon, systitle, year, imdb, tvdb)

                try:
                    overlay = int(playcount.getTVShowOverlay(indicators, tvdb))
                    if overlay == 7:
                        meta.update({'playcount': 1, 'overlay': 7})
                    else:
                        meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass

                cm = []

                if isFolder == False:
                    cm.append((control.lang(30232).encode('utf-8'),
                               'RunPlugin(%s?action=queueItem)' % sysaddon))

                if traktCredentials == True:
                    cm.append((control.lang(30236).encode(
                        'utf-8'
                    ), 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)'
                               % (sysaddon, sysname, tvdb)))

                cm.append((control.lang(30242).encode('utf-8'),
                           'RunPlugin(%s?action=trailer&name=%s)' %
                           (sysaddon, sysname)))
                cm.append(
                    (control.lang(30233).encode('utf-8'), 'Action(Info)'))
                cm.append((control.lang(30234).encode(
                    'utf-8'
                ), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)'
                           % (sysaddon, systitle, imdb, tvdb)))
                cm.append((control.lang(30235).encode(
                    'utf-8'
                ), 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)'
                           % (sysaddon, systitle, imdb, tvdb)))
                cm.append((control.lang(30240).encode('utf-8'),
                           'RunPlugin(%s?action=addView&content=tvshows)' %
                           sysaddon))

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

                try:
                    item.setArt({
                        'poster': poster,
                        'tvshow.poster': poster,
                        'season.poster': poster,
                        'banner': banner,
                        'tvshow.banner': banner,
                        'season.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.addContextMenuItems(cm, replaceItems=True)
                control.addItem(handle=int(sys.argv[1]),
                                url=url,
                                listitem=item,
                                isFolder=True)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()
            url = '%s?action=tvshows&url=%s' % (sysaddon,
                                                urllib.quote_plus(url))
            addonNext = control.addonNext()
            item = control.item(label=control.lang(30241).encode('utf-8'),
                                iconImage=addonNext,
                                thumbnailImage=addonNext)
            item.addContextMenuItems([], replaceItems=False)
            if not addonFanart == None:
                item.setProperty('Fanart_Image', addonFanart)
            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=True)
        except:
            pass

        control.content(int(sys.argv[1]), 'tvshows')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
        views.setView('tvshows', {'skin.confluence': 500})
Пример #37
0
	def tvshowDirectory(self, items, next=True):
		control.playlist.clear()
		if not items: # with reuselanguageinvoker on an empty directory must be loaded, do not use sys.exit()
			control.hide() ; control.notification(title=32002, message=33049)
		sysaddon, syshandle = argv[0], int(argv[1])
		is_widget = 'plugin' not in control.infoLabel('Container.PluginName')
		settingFanart = control.setting('fanart') == 'true'
		addonPoster, addonFanart, addonBanner = control.addonPoster(), control.addonFanart(), control.addonBanner()
		indicators = getTVShowIndicators(refresh=True)
		unwatchedEnabled = control.setting('tvshows.unwatched.enabled') == 'true'
		flatten = control.setting('flatten.tvshows') == 'true'
		if trakt.getTraktIndicatorsInfo():
			watchedMenu, unwatchedMenu = control.lang(32068), control.lang(32069)
		else:
			watchedMenu, unwatchedMenu = control.lang(32066), control.lang(32067)
		traktManagerMenu, queueMenu = control.lang(32070), control.lang(32065)
		showPlaylistMenu, clearPlaylistMenu = control.lang(35517), control.lang(35516)
		playRandom, addToLibrary = control.lang(32535), control.lang(32551)
		nextMenu = control.lang(32053)
		for i in items:
			try:
				imdb, tmdb, tvdb, year, trailer = i.get('imdb', ''), i.get('tmdb', ''), i.get('tvdb', ''), i.get('year', ''), i.get('trailer', '')
				title = i.get('tvshowtitle') or i.get('title')
				systitle = quote_plus(title)
				meta = dict((k, v) for k, v in iter(i.items()) if v is not None and v != '')
				meta.update({'code': imdb, 'imdbnumber': imdb, 'mediatype': 'tvshow', 'tag': [imdb, tmdb]}) # "tag" and "tagline" for movies only, but works in my skin mod so leave
				if unwatchedEnabled: trakt.seasonCount(imdb) # pre-cache season counts for the listed shows
				try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
				except: pass
				try:
					if 'tvshowtitle' not in meta: meta.update({'tvshowtitle': title})
				except: pass
				poster = meta.get('poster3') or meta.get('poster2') or meta.get('poster') or addonPoster
				landscape = meta.get('landscape')
				fanart = ''
				if settingFanart: fanart = meta.get('fanart3') or meta.get('fanart2') or meta.get('fanart') or landscape or addonFanart
				thumb = meta.get('thumb') or poster or landscape
				icon = meta.get('icon') or poster
				banner = meta.get('banner3') or meta.get('banner2') or meta.get('banner') or addonBanner
				art = {}
				art.update({'poster': poster, 'tvshow.poster': poster, 'fanart': fanart, 'icon': icon, 'thumb': thumb, 'banner': banner, 'clearlogo': meta.get('clearlogo', ''),
						'tvshow.clearlogo': meta.get('clearlogo', ''), 'clearart': meta.get('clearart', ''), 'tvshow.clearart': meta.get('clearart', ''), 'landscape': landscape})
				for k in ('poster2', 'poster3', 'fanart2', 'fanart3', 'banner2', 'banner3', 'trailer'): meta.pop(k, None)
				meta.update({'poster': poster, 'fanart': fanart, 'banner': banner, 'thumb': thumb, 'icon': icon})
####-Context Menu and Overlays-####
				cm = []
				try:
					overlay = int(getTVShowOverlay(indicators, imdb, tvdb))
					watched = (overlay == 5)
					if self.traktCredentials:
						cm.append((traktManagerMenu, 'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s&tvdb=%s&watched=%s)' % (sysaddon, systitle, imdb, tvdb, watched)))
					if watched:
						meta.update({'playcount': 1, 'overlay': 5})
						cm.append((unwatchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&query=4)' % (sysaddon, systitle, imdb, tvdb)))
					else:
						meta.update({'playcount': 0, 'overlay': 4})
						cm.append((watchedMenu, 'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&query=5)' % (sysaddon, systitle, imdb, tvdb)))
				except: pass
				sysmeta, sysart = quote_plus(jsdumps(meta)), quote_plus(jsdumps(art))
				cm.append(('Find similar', 'ActivateWindow(10025,%s?action=tvshows&url=https://api.trakt.tv/shows/%s/related,return)' % (sysaddon, imdb)))
				cm.append((playRandom, 'RunPlugin(%s?action=play_Random&rtype=season&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&art=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysart)))
				cm.append((queueMenu, 'RunPlugin(%s?action=playlist_QueueItem&name=%s)' % (sysaddon, systitle)))
				cm.append((showPlaylistMenu, 'RunPlugin(%s?action=playlist_Show)' % sysaddon))
				cm.append((clearPlaylistMenu, 'RunPlugin(%s?action=playlist_Clear)' % sysaddon))
				cm.append((addToLibrary, 'RunPlugin(%s?action=library_tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tmdb, tvdb)))
				cm.append(('[COLOR red]Venom Settings[/COLOR]', 'RunPlugin(%s?action=tools_openSettings)' % sysaddon))
####################################
				if flatten: url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&meta=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysmeta)
				else: url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&art=%s' % (sysaddon, systitle, year, imdb, tmdb, tvdb, sysart)
				if trailer: meta.update({'trailer': trailer})
				else: meta.update({'trailer': '%s?action=play_Trailer&type=%s&name=%s&year=%s&imdb=%s' % (sysaddon, 'show', systitle, year, imdb)})
				item = control.item(label=title, offscreen=True)
				if 'castandart' in i: item.setCast(i['castandart'])
				item.setArt(art)
				if unwatchedEnabled:
					try: 
						count = getShowCount(indicators, imdb, tvdb) # this is threaded without .join() so not all results are immediately seen
						if count:
							item.setProperties({'WatchedEpisodes': str(count['watched']), 'UnWatchedEpisodes': str(count['unwatched'])})
							item.setProperties({'TotalSeasons': str(meta.get('total_seasons', '')), 'TotalEpisodes': str(count['total'])})
						else:
							item.setProperties({'WatchedEpisodes': '0', 'UnWatchedEpisodes': str(meta.get('total_aired_episodes', ''))}) # temp use TMDb's "total_aired_episodes" for threads not finished....next load counts will update with trakt data
							item.setProperties({'TotalSeasons': str(meta.get('total_seasons', '')), 'TotalEpisodes': str(meta.get('total_aired_episodes', ''))})
					except: pass
				item.setProperty('IsPlayable', 'false')
				item.setProperty('tmdb_id', str(tmdb))
				if is_widget: item.setProperty('isVenom_widget', 'true')
				item.setUniqueIDs({'imdb': imdb, 'tmdb': tmdb, 'tvdb': tvdb})
				item.setInfo(type='video', infoLabels=control.metadataClean(meta))
				item.addContextMenuItems(cm)
				control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
			except:
				from resources.lib.modules import log_utils
				log_utils.error()
		if next:
			try:
				if not items: raise Exception()
				url = items[0]['next']
				if not url: raise Exception()
				url_params = dict(parse_qsl(urlsplit(url).query))
				if 'imdb.com' in url and 'start' in url_params:
					page = '  [I](%s)[/I]' % str(int(((int(url_params.get('start')) - 1) / int(self.page_limit)) + 1))
				else: page = '  [I](%s)[/I]' % url_params.get('page')
				nextMenu = '[COLOR skyblue]' + nextMenu + page + '[/COLOR]'
				u = urlparse(url).netloc.lower()
				if u in self.imdb_link or u in self.trakt_link:
					url = '%s?action=tvshowPage&url=%s' % (sysaddon, quote_plus(url))
				elif u in self.tmdb_link:
					url = '%s?action=tmdbTvshowPage&url=%s' % (sysaddon, quote_plus(url))
				elif u in self.tvmaze_link:
					url = '%s?action=tvmazeTvshowPage&url=%s' % (sysaddon, quote_plus(url))
				item = control.item(label=nextMenu, offscreen=True)
				icon = control.addonNext()
				item.setProperty('IsPlayable', 'false')
				item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon})
				item.setProperty ('SpecialSort', 'bottom')
				control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
			except:
				from resources.lib.modules import log_utils
				log_utils.error()
		control.content(syshandle, 'tvshows')
		control.directory(syshandle, cacheToDisc=True)
		# control.sleep(500)
		views.setView('tvshows', {'skin.estuary': 55, 'skin.confluence': 500})
Пример #38
0
    def seasonDirectory(self, items):
        if items is None or len(items) == 0:
            control.idle()
            control.notification(title=32054, message=33049, icon='INFO')
            sys.exit()

        sysaddon = sys.argv[0]
        syshandle = int(sys.argv[1])

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

        traktCredentials = trakt.getTraktCredentialsInfo()

        if trakt.getTraktIndicatorsInfo() is True:
            watchedMenu = control.lang(32068).encode('utf-8')
            unwatchedMenu = control.lang(32069).encode('utf-8')
        else:
            watchedMenu = control.lang(32066).encode('utf-8')
            unwatchedMenu = control.lang(32067).encode('utf-8')

        traktManagerMenu = control.lang(32070).encode('utf-8')
        playlistManagerMenu = control.lang(35522).encode('utf-8')
        queueMenu = control.lang(32065).encode('utf-8')
        showPlaylistMenu = control.lang(35517).encode('utf-8')
        clearPlaylistMenu = control.lang(35516).encode('utf-8')
        labelMenu = control.lang(32055).encode('utf-8')
        playRandom = control.lang(32535).encode('utf-8')
        addToLibrary = control.lang(32551).encode('utf-8')

        try:
            multi = [i['tvshowtitle'] for i in items]
        except:
            multi = []
        multi = len([x for y, x in enumerate(multi) if x not in multi[:y]])
        multi = True if multi > 1 else False

        for i in items:
            try:
                imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i[
                    'season']
                title = i['tvshowtitle']

                label = '%s %s' % (labelMenu, i['season'])

                if self.season_special is False and control.setting(
                        'tv.specials') == 'true':
                    self.season_special = True if int(season) == 0 else False

                try:
                    if i['unaired'] == 'true':
                        label = '[COLOR %s][I]%s[/I][/COLOR]' % (
                            self.unairedcolor, label)
                except:
                    pass

                systitle = sysname = urllib.quote_plus(title)

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({
                    'code': imdb,
                    'imdbnumber': imdb,
                    'imdb_id': imdb
                })
                meta.update({'tvdb_id': tvdb})
                meta.update({'mediatype': 'tvshow'})
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s' % (sysaddon, sysname)
                })

                try:
                    plot = meta['plot']
                    index = plot.rfind('See full summary')
                    if index >= 0: plot = plot[:index]
                    plot = plot.strip()
                    if re.match('[a-zA-Z\d]$', plot): plot += ' ...'
                    meta['plot'] = plot
                except:
                    pass

                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass
                try:
                    meta.update({'tvshowtitle': i['label']})
                except:
                    pass

                try:
                    # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date.
                    yearNew = i['premiered']
                    yearNew = re.findall('(\d{4})', yearNew)[0]
                    yearNew = yearNew.encode('utf-8')
                    meta.update({'year': yearNew})
                except:
                    pass

                # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
                poster = '0'
                if poster == '0' and 'thumb3' in i: poster = i['thumb3']
                if poster == '0' and 'thumb2' in i: poster = i['thumb2']
                if poster == '0' and 'thumb' in i: poster = i['thumb']
                if poster == '0' and 'poster3' in i: poster = i['poster3']
                if poster == '0' and 'poster2' in i: poster = i['poster2']
                if poster == '0' and 'poster' in i: poster = i['poster']

                icon = '0'
                if icon == '0' and 'icon3' in i: icon = i['icon3']
                if icon == '0' and 'icon2' in i: icon = i['icon2']
                if icon == '0' and 'icon' in i: icon = i['icon']

                thumb = '0'
                if thumb == '0' and 'thumb3' in i: thumb = i['thumb3']
                if thumb == '0' and 'thumb2' in i: thumb = i['thumb2']
                if thumb == '0' and 'thumb' in i: thumb = i['thumb']

                banner = '0'
                if banner == '0' and 'banner3' in i: banner = i['banner3']
                if banner == '0' and 'banner2' in i: banner = i['banner2']
                if banner == '0' and 'banner' in i: banner = i['banner']

                fanart = '0'
                if settingFanart:
                    if fanart == '0' and 'fanart3' in i: fanart = i['fanart3']
                    if fanart == '0' and 'fanart2' in i: fanart = i['fanart2']
                    if fanart == '0' and 'fanart' in i: fanart = i['fanart']

                clearlogo = '0'
                if clearlogo == '0' and 'clearlogo' in i:
                    clearlogo = i['clearlogo']

                clearart = '0'
                if clearart == '0' and 'clearart' in i:
                    clearart = i['clearart']

                if poster == '0': poster = addonPoster
                if icon == '0': icon = poster
                if thumb == '0': thumb = poster
                if banner == '0': banner = addonBanner
                if fanart == '0': fanart = addonFanart

                art = {}
                if not poster == '0' and not poster is None:
                    art.update({
                        'poster': poster,
                        'tvshow.poster': poster,
                        'season.poster': poster
                    })
                if not fanart == '0' and not fanart is None:
                    art.update({'fanart': fanart})
                if not icon == '0' and not icon is None:
                    art.update({'icon': icon})
                if not thumb == '0' and not thumb is None:
                    art.update({'thumb': thumb})
                if not banner == '0' and not banner is None:
                    art.update({'banner': banner})
                if not clearlogo == '0' and not clearlogo is None:
                    art.update({'clearlogo': clearlogo})
                if not clearart == '0' and not clearart is None:
                    art.update({'clearart': clearart})

####-Context Menu and Overlays-####
                cm = []

                if traktCredentials is True:
                    cm.append((
                        traktManagerMenu,
                        'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)'
                        % (sysaddon, sysname, imdb, tvdb, season)))

                try:
                    indicators = playcount.getSeasonIndicators(imdb)
                    overlay = int(
                        playcount.getSeasonOverlay(indicators, imdb, tvdb,
                                                   season))
                    watched = overlay == 7
                    if watched:
                        meta.update({'playcount': 1, 'overlay': 7})
                        cm.append((
                            unwatchedMenu,
                            'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                    else:
                        meta.update({'playcount': 0, 'overlay': 6})
                        cm.append((
                            watchedMenu,
                            'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                except:
                    pass

                sysmeta = urllib.quote_plus(json.dumps(meta))
                sysart = urllib.quote_plus(json.dumps(art))
                url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (
                    sysaddon, systitle, year, imdb, tvdb, season)
                sysurl = urllib.quote_plus(url)

                cm.append((
                    playRandom,
                    'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s)'
                    % (sysaddon, urllib.quote_plus(systitle),
                       urllib.quote_plus(year), urllib.quote_plus(imdb),
                       urllib.quote_plus(tvdb), urllib.quote_plus(season))))
                # cm.append((playlistManagerMenu, 'RunPlugin(%s?action=playlistManager&name=%s&url=%s&meta=%s&art=%s)' % (sysaddon, systitle, sysurl, sysmeta, sysart)))
                cm.append(
                    (queueMenu, 'RunPlugin(%s?action=queueItem&name=%s)' %
                     (sysaddon, systitle)))
                cm.append((showPlaylistMenu,
                           'RunPlugin(%s?action=showPlaylist)' % sysaddon))
                cm.append((clearPlaylistMenu,
                           'RunPlugin(%s?action=clearPlaylist)' % sysaddon))

                cm.append((
                    addToLibrary,
                    'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)'
                    % (sysaddon, systitle, year, imdb, tvdb)))
                cm.append(('[COLOR red]Venom Settings[/COLOR]',
                           'RunPlugin(%s?action=openSettings&query=(0,0))' %
                           sysaddon))
                ####################################

                item = control.item(label=label)

                unwatchedEnabled = True
                unwatchedLimit = False

                if unwatchedEnabled:
                    count = playcount.getSeasonCount(imdb, season,
                                                     self.season_special,
                                                     unwatchedLimit)
                    if count:
                        item.setProperty('TotalEpisodes', str(count['total']))
                        item.setProperty('WatchedEpisodes',
                                         str(count['watched']))
                        item.setProperty('UnWatchedEpisodes',
                                         str(count['unwatched']))

                total_seasons = trakt.getSeasons(imdb, full=False)
                if not total_seasons is None:
                    total_seasons = [i['number'] for i in total_seasons]
                    total_seasons = len(total_seasons)
                    if control.setting(
                            'tv.specials'
                    ) == 'false' or self.season_special is False:
                        total_seasons = total_seasons - 1
                    item.setProperty('TotalSeasons', str(total_seasons))

                if 'episodeIDS' in i:
                    item.setUniqueIDs(i['episodeIDS'])
                if 'cast' in i:
                    item.setCast(i['cast'])

                # if not fanart == '0' and not fanart is None:
                # item.setProperty('Fanart_Image', fanart)

                item.setArt(art)
                item.setInfo(type='video',
                             infoLabels=control.metadataClean(meta))
                item.addContextMenuItems(cm)
                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=True)
            except:
                pass

        try:
            control.property(syshandle, 'showplot', items[0]['plot'])
        except:
            pass

        control.content(syshandle, 'seasons')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
Пример #39
0
    def playlive(self, id, meta):

        meta = meta or {}

        control.log("Oi Play - play_stream: id=%s | meta=%s" % (id, meta))

        if id is None: return

        provider = meta.get('provider')
        self.isLive = meta.get('livefeed', False)

        data = self.individualize(self.isLive, id, provider)

        if not data or 'individualization' not in data:
            error_message = '%s: %s' % (
                data.get('reason'), data.get('detail')) if data and data.get(
                    'reason') else control.lang(34100).encode('utf-8')
            control.infoDialog(error_message, icon='ERROR')
            return

        encrypted = 'drm' in data and 'licenseUrl' in data['drm']

        if encrypted and not control.is_inputstream_available():
            control.okDialog(u'Oi Play', control.lang(34103).encode('utf-8'))
            return

        url = data['individualization']['url']

        # info = data.get('token', {}).get('cmsChannelItem') or data.get('token', {}).get('cmsContentItem')

        control.log("live media url: %s" % url)

        self.offset = float(meta['milliseconds_watched']
                            ) / 1000.0 if 'milliseconds_watched' in meta else 0

        parsed_url = urlparse(url)
        if ".m3u8" in parsed_url.path:
            self.url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth(
                url)
        else:
            self.url = url
            mime_type, stopEvent, cookies = 'video/mp4', None, None

        if self.url is None:
            if stopEvent:
                control.log("Setting stop event for proxy player")
                stopEvent.set()
            control.infoDialog(control.lang(34100).encode('utf-8'),
                               icon='ERROR')
            return

        control.log("Resolved URL: %s" % repr(self.url))
        control.log("Parsed URL: %s" % repr(parsed_url))

        if control.supports_offscreen:
            item = control.item(path=self.url, offscreen=True)
        else:
            item = control.item(path=self.url)
        item.setArt(meta.get('art', {}))
        item.setProperty('IsPlayable', 'true')
        item.setInfo(type='Video', infoLabels=control.filter_info_labels(meta))

        item.setContentLookup(False)

        if ".mpd" in parsed_url.path:
            mime_type = 'application/dash+xml'
            item.setProperty('inputstream.adaptive.manifest_type', 'mpd')
            if self.isLive:
                item.setProperty(
                    'inputstream.adaptive.manifest_update_parameter', 'full')

        else:
            item.setProperty('inputstream.adaptive.manifest_type', 'hls')

        if encrypted:
            control.log("DRM: com.widevine.alpha")
            # licence_url = data['drm']['licenseUrl'] + '&token=' + data['drm']['jwtToken']
            if data.get('drm', {}).get('jwtToken'):
                licence_url = '%s&token=%s' % (data.get(
                    'drm', {}).get('licenseUrl'), data.get('drm',
                                                           {}).get('jwtToken'))
            else:
                licence_url = data.get('drm', {}).get('licenseUrl')
            item.setProperty('inputstream.adaptive.license_type',
                             'com.widevine.alpha')
            item.setProperty('inputstream.adaptive.license_key',
                             licence_url + "||R{SSM}|")

        if mime_type:
            item.setMimeType(mime_type)
            control.log("MIME TYPE: %s" % repr(mime_type))

        if not cookies and control.is_inputstream_available():
            item.setProperty('inputstreamaddon', 'inputstream.adaptive')

        # if 'subtitles' in info and info['subtitles'] and len(info['subtitles']) > 0:
        #     control.log("FOUND SUBTITLES: %s" % repr([sub['url'] for sub in info['subtitles']]))
        #     item.setSubtitles([sub['url'] for sub in info['subtitles']])

        control.resolve(int(sys.argv[1]), True, item)

        self.stopPlayingEvent = threading.Event()
        self.stopPlayingEvent.clear()

        first_run = True
        # last_time = 0.0
        while not self.stopPlayingEvent.isSet():
            if control.monitor.abortRequested():
                control.log("Abort requested")
                break

            if self.isPlaying():
                if first_run:
                    self.showSubtitles(False)
                    first_run = False
                # if not self.isLive:
                #     current_time = self.getTime()
                #     if current_time - last_time > 5 or (last_time == 0 and current_time > 1):
                #         last_time = current_time
                #         self.save_video_progress(self.token, self.video_id, current_time)
            control.sleep(1000)

        if stopEvent:
            control.log("Setting stop event for proxy player")
            stopEvent.set()

        control.log("Done playing. Quitting...")
Пример #40
0
    def playlive(self, id, meta):

        if id is None: return

        info = resourceshelper.get_video_info(id)

        control.log("INFO: %s" % repr(info))

        if not info or info is None or 'channel' not in info:
            return

        try:
            hash, user, credentials = self.sign_resource(info['provider_id'], info['resource_id'], id, info['player'], info['version'])
        except Exception as ex:
            control.log("ERROR: %s" % repr(ex))
            return

        encrypted = 'encrypted' in info and info['encrypted']

        if encrypted and not control.is_inputstream_available():
            control.infoDialog(message=control.lang(34103).encode('utf-8'), icon='Wr')
            return

        title = info['channel']

        query_string = re.sub(r'{{(\w*)}}', r'%(\1)s', info['query_string_template'])

        query_string = query_string % {
            'hash': hash,
            'key': 'app',
            'openClosed': 'F' if info['subscriber_only'] else 'A',
            'user': user if info['subscriber_only'] else ''
        }

        url = '?'.join([info['url'], query_string])

        control.log("live media url: %s" % url)

        try:
            meta = json.loads(meta)
        except:
            meta = {
                "playcount": 0,
                "overlay": 6,
                "title": title,
                "thumb": info["thumbUri"],
                "mediatype": "video",
                "aired": info["exhibited_at"]
            }

        meta.update({
            "genre": info["category"],
            "plot": info["title"],
            "plotoutline": info["title"]
        })

        poster = meta['poster'] if 'poster' in meta else control.addonPoster()
        thumb = meta['thumb'] if 'thumb' in meta else info["thumbUri"]

        self.offset = float(meta['milliseconds_watched']) / 1000.0 if 'milliseconds_watched' in meta else 0

        self.isLive = 'livefeed' in meta and meta['livefeed'] == 'true'

        parsed_url = urlparse(url)
        if parsed_url.path.endswith(".m3u8"):
            self.url, mime_type, stopEvent, cookies = hlshelper.pick_bandwidth(url)
        else:
            self.url = url
            mime_type, stopEvent, cookies = 'video/mp4', None, None

        if self.url is None:
            if stopEvent:
                control.log("Setting stop event for proxy player")
                stopEvent.set()
            control.infoDialog(control.lang(34100).encode('utf-8'), icon='ERROR')
            return

        control.log("Resolved URL: %s" % repr(self.url))
        control.log("Parsed URL: %s" % repr(parsed_url))

        item = control.item(path=self.url)
        item.setArt({'icon': thumb, 'thumb': thumb, 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster})
        item.setProperty('IsPlayable', 'true')
        item.setInfo(type='Video', infoLabels=meta)

        item.setContentLookup(False)

        if parsed_url.path.endswith(".mpd"):
            mime_type = 'application/dash+xml'
            item.setProperty('inputstream.adaptive.manifest_type', 'mpd')

        elif parsed_url.path.endswith(".ism/manifest"):
            mime_type = 'application/vnd.ms-sstr+xml'
            item.setProperty('inputstream.adaptive.manifest_type', 'ism')

        else:
            item.setProperty('inputstream.adaptive.manifest_type', 'hls')

        if encrypted:
            control.log("DRM: %s" % info['drm_scheme'])
            licence_url = info['protection_url']
            item.setProperty('inputstream.adaptive.license_type', info['drm_scheme'])
            if info['drm_scheme'] == 'com.widevine.alpha' or info['drm_scheme'] == 'com.microsoft.playready':
                item.setProperty('inputstream.adaptive.license_key', licence_url + "||R{SSM}|")

        if mime_type:
            item.setMimeType(mime_type)
            control.log("MIME TYPE: %s" % repr(mime_type))

        if not cookies and not control.disable_inputstream_adaptive:
            item.setProperty('inputstreamaddon', 'inputstream.adaptive')

        if 'subtitles' in info and info['subtitles'] and len(info['subtitles']) > 0:
            control.log("FOUND SUBTITLES: %s" % repr([sub['url'] for sub in info['subtitles']]))
            item.setSubtitles([sub['url'] for sub in info['subtitles']])

        control.resolve(int(sys.argv[1]), True, item)

        self.stopPlayingEvent = threading.Event()
        self.stopPlayingEvent.clear()

        self.token = auth_helper.get_globosat_token()

        self.video_id = info['id'] if 'id' in info else None

        first_run = True
        last_time = 0.0
        while not self.stopPlayingEvent.isSet():
            if control.monitor.abortRequested():
                control.log("Abort requested")
                break

            if self.isPlaying():
                if first_run:
                    self.showSubtitles(False)
                    first_run = False
                if not self.isLive:
                    current_time = self.getTime()
                    if current_time - last_time > 5 or (last_time == 0 and current_time > 1):
                        last_time = current_time
                        self.save_video_progress(self.token, self.video_id, current_time)
            control.sleep(1000)

        if stopEvent:
            control.log("Setting stop event for proxy player")
            stopEvent.set()

        control.log("Done playing. Quitting...")
Пример #41
0
    def play_source(self,
                    title,
                    year,
                    season,
                    episode,
                    imdb,
                    tmdb,
                    tvdb,
                    url,
                    meta,
                    select=None):
        try:
            if not url: raise Exception
            self.media_type = 'movie' if season is None or episode is None else 'episode'
            self.title = title
            self.year = str(year)
            if self.media_type == 'movie':
                self.name = '%s (%s)' % (title, self.year)
                self.season = None
                self.episode = None
            elif self.media_type == 'episode':
                self.name = '%s S%02dE%02d' % (title, int(season),
                                               int(episode))
                self.season = '%01d' % int(season)
                self.episode = '%01d' % int(episode)

            self.DBID = None
            self.imdb = imdb if imdb is not None else ''
            self.tmdb = tmdb if tmdb is not None else ''
            self.tvdb = tvdb if tvdb is not None else ''
            self.ids = {
                'imdb': self.imdb,
                'tmdb': self.tmdb,
                'tvdb': self.tvdb
            }

            ## - compare meta received to database and use largest(eventually switch to a request to fetch missing db meta for item)
            self.imdb_user = control.setting('imdb.user').replace('ur', '')
            self.tmdb_key = control.setting('tmdb.api.key')
            if not self.tmdb_key:
                self.tmdb_key = '3320855e65a9758297fec4f7c9717698'
            self.tvdb_key = control.setting('tvdb.api.key')
            if self.media_type == 'episode':
                self.user = str(self.imdb_user) + str(self.tvdb_key)
            else:
                self.user = str(self.tmdb_key)
            self.lang = control.apiLanguage()['tvdb']
            meta1 = meta
            meta2 = metacache.fetch([{
                'imdb': self.imdb,
                'tmdb': self.tmdb,
                'tvdb': self.tvdb
            }], self.lang, self.user)[0]
            if meta2 != self.ids:
                meta2 = dict((k, v) for k, v in control.iteritems(meta2)
                             if v is not None and v != '')
            if meta1 is not None:
                try:
                    if len(meta2) > len(meta1):
                        meta2.update(meta1)
                        meta = meta2
                    else:
                        meta = meta1
                except:
                    log_utils.error()
            else:
                meta = meta2 if meta2 != self.ids else meta1
            ##################
            self.meta = meta
            poster, thumb, season_poster, fanart, banner, clearart, clearlogo, discart, meta = self.getMeta(
                meta)
            runtime = meta.get('duration') if meta else 0
            self.offset = Bookmarks().get(name=self.name,
                                          imdb=imdb,
                                          tmdb=tmdb,
                                          tvdb=tvdb,
                                          season=season,
                                          episode=episode,
                                          year=self.year,
                                          runtime=runtime)
            item = control.item(path=url)
            item.setUniqueIDs(self.ids)
            if control.setting('disable.player.art') == 'true':
                for k in ('clearart', 'clearlogo', 'discart'):
                    meta.pop(k, None)
            if self.media_type == 'episode':
                if control.setting('disable.player.art') == 'true':
                    item.setArt({
                        'thumb': thumb,
                        'tvshow.poster': season_poster,
                        'season.poster': season_poster,
                        'tvshow.fanart': fanart
                    })
                else:
                    item.setArt({
                        'tvshow.clearart': clearart,
                        'tvshow.clearlogo': clearlogo,
                        'tvshow.discart': discart,
                        'thumb': thumb,
                        'tvshow.poster': season_poster,
                        'season.poster': season_poster,
                        'tvshow.fanart': fanart
                    })
            else:
                if control.setting('disable.player.art') == 'true':
                    item.setArt({
                        'thumb': thumb,
                        'poster': poster,
                        'fanart': fanart
                    })
                else:
                    item.setArt({
                        'clearart': clearart,
                        'clearlogo': clearlogo,
                        'discart': discart,
                        'thumb': thumb,
                        'poster': poster,
                        'fanart': fanart
                    })

            if 'castandart' in meta: item.setCast(meta.get('castandart', ''))
            item.setInfo(type='video', infoLabels=control.metadataClean(meta))
            if 'plugin' not in control.infoLabel(
                    'Container.PluginName') or select != '1':
                control.busy()
                control.resolve(int(argv[1]), True, item)
            elif select == '1':
                control.busy()
                control.player.play(url, item)
            control.homeWindow.setProperty('script.trakt.ids',
                                           jsdumps(self.ids))
            self.keepAlive()
            control.homeWindow.clearProperty('script.trakt.ids')
        except:
            log_utils.error()
            return control.cancelPlayback()
Пример #42
0
    def channelDirectory(self, items):
        if items == None or len(items) == 0:
            control.idle()
            sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

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

        try:
            isOld = False
            control.item().getArt('type')
        except:
            isOld = True

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

        playbackMenu = control.lang(32063).encode('utf-8') if control.setting(
            'hosts.mode') == '2' else control.lang(32064).encode('utf-8')

        queueMenu = control.lang(32065).encode('utf-8')

        refreshMenu = control.lang(32072).encode('utf-8')

        for i in items:
            try:
                label = '[B]%s[/B] : %s (%s)' % (i['channel'].upper(),
                                                 i['title'], i['year'])
                sysname = urllib.quote_plus('%s (%s)' %
                                            (i['title'], i['year']))
                systitle = urllib.quote_plus(i['title'])
                imdb, tmdb, year = i['imdb'], i['tmdb'], i['year']

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({
                    'code': imdb,
                    'imdbnumber': imdb,
                    'imdb_id': imdb
                })
                meta.update({'tmdb_id': tmdb})
                meta.update({'mediatype': 'movie'})
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s' % (sysaddon, sysname)
                })
                #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb})
                meta.update({'playcount': 0, 'overlay': 6})
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass

                sysmeta = urllib.quote_plus(json.dumps(meta))

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

                cm = []

                cm.append(
                    (queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

                cm.append(
                    (refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon))

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

                if isOld == True:
                    cm.append(
                        (control.lang2(19033).encode('utf-8'), 'Action(Info)'))

                item = control.item(label=label)

                art = {}

                if 'poster2' in i and not i['poster2'] == '0':
                    art.update({
                        'icon': i['poster2'],
                        'thumb': i['poster2'],
                        'poster': i['poster2']
                    })
                elif 'poster' in i and not i['poster'] == '0':
                    art.update({
                        'icon': i['poster'],
                        'thumb': i['poster'],
                        'poster': i['poster']
                    })
                else:
                    art.update({
                        'icon': addonPoster,
                        'thumb': addonPoster,
                        'poster': addonPoster
                    })

                art.update({'banner': addonBanner})

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

                item.setArt(art)
                item.addContextMenuItems(cm)
                item.setProperty('IsPlayable', isPlayable)
                item.setInfo(type='Video', infoLabels=meta)

                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)

                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=False)
            except:
                pass

        control.content(syshandle, 'files')
        control.directory(syshandle, cacheToDisc=True)
Пример #43
0
    def addDirectory(self, items, queue=False):
        if items == None or len(items) == 0: return

        sysaddon = sys.argv[0]
        addonPoster = addonBanner = control.addonInfo('icon')
        addonFanart = control.addonInfo('fanart')

        playlist = control.playlist
        if not queue == False: playlist.clear()

        try:
            devmode = True if 'testings.xml' in control.listDir(
                control.dataPath)[1] else False
        except:
            devmode = False

        mode = [i['content'] for i in items if 'content' in i]
        if 'movies' in mode: mode = 'movies'
        elif 'tvshows' in mode: mode = 'tvshows'
        elif 'seasons' in mode: mode = 'seasons'
        elif 'episodes' in mode: mode = 'episodes'
        elif 'videos' in mode: mode = 'videos'
        else: mode = 'addons'

        for i in items:
            try:
                try:
                    name = control.lang(int(i['name'])).encode('utf-8')
                except:
                    name = i['name']

                url = '%s?action=%s' % (sysaddon, i['action'])
                try:
                    url += '&url=%s' % urllib.quote_plus(i['url'])
                except:
                    pass
                try:
                    url += '&content=%s' % urllib.quote_plus(i['content'])
                except:
                    pass

                if i['action'] == 'plugin' and 'url' in i: url = i['url']

                try:
                    devurl = dict(
                        urlparse.parse_qsl(
                            urlparse.urlparse(url).query))['action']
                except:
                    devurl = None
                if devurl == 'developer' and not devmode == True:
                    raise Exception()

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

                content = i['content'] if 'content' in i else '0'

                folder = i['folder'] if 'folder' in i else True

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')

                cm = []

                if content in ['movies', 'tvshows']:
                    meta.update({
                        'trailer':
                        '%s?action=trailer&name=%s' %
                        (sysaddon, urllib.quote_plus(name))
                    })
                    cm.append((control.lang(30707).encode('utf-8'),
                               'RunPlugin(%s?action=trailer&name=%s)' %
                               (sysaddon, urllib.quote_plus(name))))

                if content in ['movies', 'tvshows', 'seasons', 'episodes']:
                    cm.append((control.lang(30708).encode('utf-8'),
                               'XBMC.Action(Info)'))

                if (folder == False and not '|regex=' in str(i.get('url'))
                    ) or (folder == True
                          and content in ['tvshows', 'seasons']):
                    cm.append((control.lang(30723).encode('utf-8'),
                               'RunPlugin(%s?action=queueItem)' % sysaddon))

                if content == 'movies':
                    try:
                        dfile = '%s (%s)' % (i['title'], i['year'])
                    except:
                        dfile = name
                    try:
                        cm.append((control.lang(30722).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)'
                                   % (sysaddon, urllib.quote_plus(dfile),
                                      urllib.quote_plus(i['url']),
                                      urllib.quote_plus(poster))))
                    except:
                        pass
                elif content == 'episodes':
                    try:
                        dfile = '%s S%02dE%02d' % (i['tvshowtitle'],
                                                   int(i['season']),
                                                   int(i['episode']))
                    except:
                        dfile = name
                    try:
                        cm.append((control.lang(30722).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)'
                                   % (sysaddon, urllib.quote_plus(dfile),
                                      urllib.quote_plus(i['url']),
                                      urllib.quote_plus(poster))))
                    except:
                        pass
                elif content == 'songs':
                    try:
                        cm.append((control.lang(30722).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)'
                                   % (sysaddon, urllib.quote_plus(name),
                                      urllib.quote_plus(i['url']),
                                      urllib.quote_plus(poster))))
                    except:
                        pass

                if mode == 'movies':
                    cm.append((control.lang(30711).encode('utf-8'),
                               'RunPlugin(%s?action=addView&content=movies)' %
                               sysaddon))
                elif mode == 'tvshows':
                    cm.append((control.lang(30712).encode('utf-8'),
                               'RunPlugin(%s?action=addView&content=tvshows)' %
                               sysaddon))
                elif mode == 'seasons':
                    cm.append((control.lang(30713).encode('utf-8'),
                               'RunPlugin(%s?action=addView&content=seasons)' %
                               sysaddon))
                elif mode == 'episodes':
                    cm.append(
                        (control.lang(30714).encode('utf-8'),
                         'RunPlugin(%s?action=addView&content=episodes)' %
                         sysaddon))

                if devmode == True:
                    try:
                        cm.append(('Open in browser',
                                   'RunPlugin(%s?action=browser&url=%s)' %
                                   (sysaddon, urllib.quote_plus(i['url']))))
                    except:
                        pass

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

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

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

                if queue == False:
                    item.setInfo(type='Video', infoLabels=meta)
                    item.addContextMenuItems(cm)
                    control.addItem(handle=int(sys.argv[1]),
                                    url=url,
                                    listitem=item,
                                    isFolder=folder)
                else:
                    item.setInfo(type='Video', infoLabels=meta)
                    playlist.add(url=url, listitem=item)
            except:
                pass

        if not queue == False:
            return control.player.play(playlist)

        try:
            i = items[0]
            if i['next'] == '': raise Exception()
            url = '%s?action=%s&url=%s' % (sysaddon, i['nextaction'],
                                           urllib.quote_plus(i['next']))
            item = control.item(label=control.lang(30500).encode('utf-8'))
            item.setArt({
                'addonPoster': addonPoster,
                'thumb': addonPoster,
                'poster': addonPoster,
                'tvshow.poster': addonPoster,
                'season.poster': addonPoster,
                'banner': addonPoster,
                'tvshow.banner': addonPoster,
                'season.banner': addonPoster
            })
            item.setProperty('addonFanart_Image', addonFanart)
            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=True)
        except:
            pass

        if not mode == None: control.content(int(sys.argv[1]), mode)
        control.directory(int(sys.argv[1]), cacheToDisc=True)
        if mode in ['movies', 'tvshows', 'seasons', 'episodes']:
            views.setView(mode, {'skin.estuary': 55})
Пример #44
0
    def run(self,
            title,
            year,
            season,
            episode,
            imdb,
            tvdb,
            tmdb,
            url,
            meta,
            id,
            directPlay=False):
        try:
            control.sleep(200)
            self.autoResume = control.setting('bookmarks.autoresume')
            self.nextup_timeout = control.setting('nextup.timeout')
            self.nextup_service = control.setting('nextup.service')
            self.next_episode = []
            self.seekStatus = False
            infoMeta = False
            self.filetype = 'unknown'
            self.watched = False

            self.totalTime = 0
            self.currentTime = 0
            self.lastProgress = 0
            self.original_meta = meta
            self.content = 'movie' if season == None or episode == None else 'episode'

            if self.content == 'movie' and imdb != '0' and imdb != None:
                self.filetype = 'movie'
                infoMeta = True
            else:
                infoMeta = False

            if self.content == 'episode' and imdb != '0' and imdb != None:
                self.filetype = 'episode'
                infoMeta = True

            elif self.content == 'episode' and tvdb != '0' and tvdb != None:
                self.filetype = 'episode'
                infoMeta = True

            else:
                infoMeta = False

            self.tvshowtitle = title
            self.title = title
            self.year = year

            if infoMeta == True:
                self.name = urllib.parse.quote_plus(
                    title) + urllib.parse.quote_plus(
                        ' (%s)' % year
                    ) if self.content == 'movie' else urllib.parse.quote_plus(
                        title) + urllib.parse.quote_plus(
                            ' S%02dE%02d' % (int(season), int(episode)))
            else:
                self.name = urllib.parse.quote_plus(title)
            self.bookMarkName = urllib.parse.unquote_plus(self.name)
            self.season = '%01d' % int(
                season) if self.content == 'episode' else None
            self.episode = '%01d' % int(
                episode) if self.content == 'episode' else None
            # self.Nextup = None
            self.DBID = None

            try:
                plot = meta['plot']
            except:
                plot = ''

            self.FileId = id
            self.imdb = imdb if not imdb == None else '0'
            self.tvdb = tvdb if not tvdb == None else '0'
            self.season = '%01d' % int(
                season) if self.content == 'episode' else None
            self.episode = '%01d' % int(
                episode) if self.content == 'episode' else None

            self.metaID = [self.imdb, self.tvdb]
            self.metaID = [i for i in self.metaID if not str(i) == '0']
            if self.content == 'movie': self.ids = {'imdb': self.imdb}
            else: self.ids = {'imdb': self.imdb, 'tvdb': self.imdb}
            self.ids = dict(
                (k, v) for k, v in self.ids.items() if not v == '0')

            poster, thumb, fanart, meta = self.getMeta(meta)

            item = control.item(path=url)
            self.infolabels = {"Title": title, "Plot": plot, "year": self.year}
            if self.content == 'episode' and infoMeta == True:
                self.infolabels.update({
                    "season": meta['season'],
                    "episode": meta['episode'],
                    "tvshowtitle": meta['tvshowtitle'],
                    "showtitle": meta['tvshowtitle'],
                    "tvdb": self.tvdb
                })
            self.original_meta = meta

            if self.content == 'episode':
                item.setArt({
                    'icon': thumb,
                    'thumb': fanart,
                    'poster': poster,
                    'fanart': fanart,
                    'tvshow.poster': poster,
                    'season.poster': thumb,
                    'tvshow.landscape': thumb
                })
            else:
                item.setArt({
                    'icon': thumb,
                    'thumb': thumb,
                    'poster': thumb,
                    'fanart': thumb
                })

            item.setInfo(type='Video', infoLabels=self.infolabels)

            control.player.play(url, item)

            control.resolve(int(sys.argv[1]), True, item)

            control.window.setProperty('script.trakt.ids',
                                       json.dumps(self.ids))

            self.keepPlaybackAlive()

            control.window.clearProperty('script.trakt.ids')

        except:
            return
Пример #45
0
    def my_downloads_to_listItem(self, page):
        try:
            from datetime import datetime
            sysaddon = sys.argv[0]
            syshandle = int(sys.argv[1])
            my_downloads, pages = self.downloads(page)
        except:
            my_downloads = None

        if not my_downloads:
            return
        extensions = supported_video_extensions()
        my_downloads = [
            i for i in my_downloads
            if i['download'].lower().endswith(tuple(extensions))
        ]
        downloadMenu, deleteMenu = control.lang(40048), control.lang(40050)

        for count, item in enumerate(my_downloads, 1):
            if page > 1:
                count += (page - 1) * 50
            try:
                cm = []
                generated = datetime.strptime(item['generated'],
                                              FormatDateTime)
                generated = generated.strftime('%Y-%m-%d')
                name = control.strip_non_ascii_and_unprintable(
                    item['filename'])

                size = float(int(item['filesize'])) / 1073741824
                label = '%02d | %.2f GB | %s  | [I]%s [/I]' % (count, size,
                                                               generated, name)

                url_link = item['download']
                url = '%s?action=playURL&url=%s' % (sysaddon, url_link)
                cm.append((
                    downloadMenu,
                    'RunPlugin(%s?action=download&name=%s&image=%s&url=%s&caller=realdebrid)'
                    % (sysaddon, quote_plus(name), quote_plus(rd_icon),
                       url_link)))

                cm.append(
                    (deleteMenu % 'File',
                     'RunPlugin(%s?action=rd_DeleteDownload&id=%s&name=%s)' %
                     (sysaddon, item['id'], name)))

                item = control.item(label=label)
                item.addContextMenuItems(cm)
                item.setArt({
                    'icon': rd_icon,
                    'poster': rd_icon,
                    'thumb': rd_icon,
                    'fanart': addonFanart,
                    'banner': rd_icon
                })
                item.setInfo(type='video', infoLabels='')
                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=False)
            except:
                log_utils.error()
                pass

        if page < pages:
            page += 1
            next = True
        else:
            next = False

        if next:
            try:
                nextMenu = control.lang(32053)
                url = '%s?action=rd_MyDownloads&query=%s' % (sysaddon, page)
                page = '  [I](%s)[/I]' % page
                nextMenu = '[COLOR skyblue]' + nextMenu + page + '[/COLOR]'
                item = control.item(label=nextMenu)
                icon = control.addonNext()
                item.setArt({
                    'icon': rd_icon,
                    'poster': rd_icon,
                    'thumb': rd_icon,
                    'fanart': addonFanart,
                    'banner': rd_icon
                })
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=True)
            except:
                log_utils.error()
                pass
        control.content(syshandle, 'files')
        control.directory(syshandle, cacheToDisc=True)
Пример #46
0
    def movieDirectory(self, items):
        if items == None or len(items) == 0: return

        isFolder = True if control.setting('autoplay') == 'false' and control.setting('hosts.mode') == '1' else False
        isFolder = False if control.window.getProperty('PseudoTVRunning') == 'True' else isFolder

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

        traktCredentials = trakt.getTraktCredentialsInfo()

        indicators = playcount.getMovieIndicators()

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

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart, settingFanart = control.addonFanart(), control.setting('fanart')
        sysaddon = sys.argv[0]

        for i in items:
            try:
                label = '%s (%s)' % (i['title'], i['year'])
                imdb, title, year = i['imdb'], i['originaltitle'], i['year']
                sysname = urllib.quote_plus('%s (%s)' % (title, year))
                sysimage = urllib.quote_plus(i['poster'])
                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' % (sysaddon, sysname)})
                if i['duration'] == '0': meta.update({'duration': '120'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
                except: pass
                try: del meta['tagline']
                except: pass
                sysmeta = urllib.quote_plus(json.dumps(meta))


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

                path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb)

                if isFolder == True:
                    url = '%s?action=sources&title=%s&year=%s&imdb=%s&meta=%s' % (sysaddon, systitle, year, imdb, sysmeta)


                try:
                    overlay = int(playcount.getMovieOverlay(indicators, imdb))
                    if overlay == 7: meta.update({'playcount': 1, 'overlay': 7})
                    else: meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass

                cm = []

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

                if isFolder == False:
                    cm.append((control.lang(30202).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon))

                if traktCredentials == True:
                    cm.append((control.lang(30208).encode('utf-8'), 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb)))

                cm.append((control.lang(30214).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname)))
                cm.append((control.lang(30205).encode('utf-8'), 'Action(Info)'))
                cm.append((control.lang(30206).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb)))
                cm.append((control.lang(30207).encode('utf-8'), 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb)))
                cm.append((control.lang(30212).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon))


                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', 'true')
                item.addContextMenuItems(cm, replaceItems=True)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder)
            except:
                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([], replaceItems=True)
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
        except:
            pass


        control.content(int(sys.argv[1]), 'movies')
        control.directory(int(sys.argv[1]), cacheToDisc=cacheToDisc)
        views.setView('movies', {'skin.confluence': 500})
Пример #47
0
def addDirectoryItem(name, url, action, image, image2, fanart, audio, content, data, tvshow='0', totalItems=0, isFolder=True):
    if not str(image).lower().startswith('http'): image = control.addonInfo('icon')

    if not str(image2).lower().startswith('http'): image2 = control.addonInfo('icon')

    if not str(fanart).lower().startswith('http'): fanart = control.addonInfo('fanart')

    if content in ['movies', 'episodes']: playable = 'true'
    else: playable = 'false'

    sysaddon = sys.argv[0]

    u = '%s?name=%s&url=%s&audio=%s&image=%s&fanart=%s&playable=%s&tvshow=%s&content=%s&action=%s' % (sysaddon, urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(audio), urllib.quote_plus(image), urllib.quote_plus(fanart), urllib.quote_plus(playable), str(tvshow), str(content), str(action))

    cm = []

    if content in ['movies', 'tvshows']:
        data.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(name))})
        cm.append((control.lang(30707).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, urllib.quote_plus(name))))

    if not 'plot' in data:
        data.update({'plot': control.lang(30706).encode('utf-8')})


    if content == 'movies':
        cm.append((control.lang(30708).encode('utf-8'), 'XBMC.Action(Info)'))
    elif content in ['tvshows', 'seasons']:
        cm.append((control.lang(30709).encode('utf-8'), 'XBMC.Action(Info)'))
    elif content == 'episodes':
        cm.append((control.lang(30710).encode('utf-8'), 'XBMC.Action(Info)'))


    if content == 'movies' and not isFolder == True:
        downloadFile = name
        try: downloadFile = '%s (%s)' % (data['title'], data['year'])
        except: pass
        cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image))))

    elif content == 'episodes' and not isFolder == True:
        downloadFile = name
        try: downloadFile = '%s S%02dE%02d' % (data['tvshowtitle'], int(data['season']), int(data['episode']))
        except: pass
        cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image))))


    if content == 'movies':
        cm.append((control.lang(30711).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon))
    elif content == 'tvshows':
        cm.append((control.lang(30712).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon))
    elif content == 'seasons':
        cm.append((control.lang(30713).encode('utf-8'), 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon))
    elif content == 'episodes':
        cm.append((control.lang(30714).encode('utf-8'), 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon))


    item = control.item(name, iconImage='DefaultFolder.png', thumbnailImage=image)
    try: item.setArt({'poster': image2, 'tvshow.poster': image2, 'season.poster': image2, 'banner': image, 'tvshow.banner': image, 'season.banner': image})
    except: pass
    item.addContextMenuItems(cm, replaceItems=False)
    item.setProperty('Fanart_Image', fanart)
    if playable == 'true': item.setProperty('IsPlayable', 'true')
    item.setInfo(type='Video', infoLabels=data)

    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,totalItems=totalItems,isFolder=isFolder)
Пример #48
0
def resolveUrl(name, url, audio, image, fanart, playable, content):
    try:
        if '.f4m'in url:
            label = cleantitle(name)
            ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower()
            if not ext == 'f4m': raise Exception()
            from resources.lib.libraries.f4mproxy.F4mProxy import f4mProxyHelper
            return f4mProxyHelper().playF4mLink(url, label, None, None,'',image)


        #legacy issue, will be removed later
        if 'afdah.org' in url and not '</source>' in url: url += '<source>afdah</source>'

        if '</source>' in url:
            source = re.compile('<source>(.+?)</source>').findall(url)[0]
            url = re.compile('(.+?)<source>').findall(url)[0]

            for i in ['_mv', '_tv', '_mv_tv']:
                try: call = __import__('resources.lib.sources.%s%s' % (source, i), globals(), locals(), ['object'], -1).source()
                except: pass

            from resources.lib import sources ; d = sources.sources()

            url = call.get_sources(url, d.hosthdfullDict, d.hostsdfullDict, d.hostlocDict)

            if type(url) == list and len(url) == 1:
                url = url[0]['url']

            elif type(url) == list:
                url = sorted(url, key=lambda k: k['quality'])
                for i in url: i.update((k, '720p') for k, v in i.iteritems() if v == 'HD')
                for i in url: i.update((k, '480p') for k, v in i.iteritems() if v == 'SD')
                q = ['[B]%s[/B] | %s' % (i['source'].upper(), i['quality'].upper()) for i in url]
                u = [i['url'] for i in url]
                select = control.selectDialog(q)
                if select == -1: return
                url = u[select]

            url = call.resolve(url)


        from resources.lib import resolvers
        host = (urlparse.urlparse(url).netloc).rsplit('.', 1)[0].rsplit('.')[-1]
        url = resolvers.request(url)

        if type(url) == list and len(url) == 1:
            url = url[0]['url']

        elif type(url) == list:
            url = sorted(url, key=lambda k: k['quality'])
            for i in url: i.update((k, '720p') for k, v in i.iteritems() if v == 'HD')
            for i in url: i.update((k, '480p') for k, v in i.iteritems() if v == 'SD')
            q = ['[B]%s[/B] | %s' % (host.upper(), i['quality'].upper()) for i in url]
            u = [i['url'] for i in url]
            select = control.selectDialog(q)
            if select == -1: return
            url = u[select]

        if url == None: raise Exception()
    except:
        return control.infoDialog(control.lang(30705).encode('utf-8'))
        pass


    if playable == 'true':
        item = control.item(path=url)
        return control.resolve(int(sys.argv[1]), True, item)
    else:
        label = cleantitle(name)
        item = control.item(path=url, iconImage=image, thumbnailImage=image)
        item.setInfo( type='Video', infoLabels = {'title': label} )
        control.playlist.clear()
        control.player.play(url, item)
Пример #49
0
                myLists.addList(name, path)

elif mode[0] == 'remove_list':
    name = args['name'][0]
    myLists.removeList(name)
    control.refresh()

elif mode[0] == 'open_list':
    path = args['path'][0]
    items = myLists.getItems(path)
    for item in items:
        url = item[0]
        if url.endswith('.ts'):
            import liveresolver
            url = liveresolver.resolve(url, title=item[1])
            item = control.item(item[1], item[2])
            control.addItem(handle=addon_handle, url=url, listitem=item)
        else:
            addon.add_video_item(
                {
                    'mode': 'play_playlist',
                    'url': item[0],
                    'title': item[1],
                    'img': item[2]
                }, {'title': item[1]},
                img=item[2],
                fanart=fanart)
    addon.end_of_directory()

elif mode[0] == 'play_playlist':
    url = args['url'][0]
Пример #50
0
def downloader():

    thumb = control.addonThumb()
    fanart = control.addonFanart()

    status = control.window.getProperty(property + '.status')

    if not downloadPath == '':
        item = control.item('[COLOR FF00b8ff]Downloads[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]),
                        url=downloadPath,
                        listitem=item,
                        isFolder=True)

    if status == 'downloading':
        item = control.item('[COLOR red]Stop Downloads[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]),
                        url=sys.argv[0] + '?action=stopDownload',
                        listitem=item,
                        isFolder=True)
    else:
        item = control.item('[COLOR FF00b8ff]Start Downloads[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
        control.addItem(handle=int(sys.argv[1]),
                        url=sys.argv[0] + '?action=startDownload',
                        listitem=item,
                        isFolder=True)

    if status == 'downloading':
        item = control.item('[COLOR gold]Download Status[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('Fanart_Image', fanart)
        control.addItem(handle=int(sys.argv[1]),
                        url=sys.argv[0] + '?action=statusDownload',
                        listitem=item,
                        isFolder=True)

    def download():
        return []

    result = cache.Asylum_download_get(download, 600000000, table='rel_dl')

    for i in result:
        try:
            cm = []
            cm.append(('Remove from Queue',
                       'RunPlugin(%s?action=removeDownload&url=%s)' %
                       (sys.argv[0], urllib.quote_plus(i['url']))))
            item = control.item(i['name'],
                                iconImage=i['image'],
                                thumbnailImage=i['image'])
            item.addContextMenuItems(cm, replaceItems=True)
            item.setProperty('fanart_image', fanart)
            item.setProperty('Video', 'true')
            item.setProperty('IsPlayable', 'true')
            control.addItem(handle=int(sys.argv[1]),
                            url=i['url'],
                            listitem=item)
        except:
            pass

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #51
0
    def browse_user_torrents(self, folder_id):
        try:
            sysaddon = sys.argv[0]
            syshandle = int(sys.argv[1])
            torrent_files = self.torrent_info(folder_id)
        except:
            return
        extensions = supported_video_extensions()
        try:
            file_info = [
                i for i in torrent_files['files']
                if i['path'].lower().endswith(tuple(extensions))
            ]
            file_urls = torrent_files['links']
            for c, i in enumerate(file_info):
                try:
                    i.update({'url_link': file_urls[c]})
                except:
                    pass
            pack_info = sorted(file_info, key=lambda k: k['path'])
        except:
            return control.notification(title='default',
                                        message=33586,
                                        icon='default')

        file_str, downloadMenu, renameMenu, deleteMenu, clearFinishedMenu = \
          control.lang(40047).upper(), control.lang(40048), control.lang(40049), control.lang(40050), control.lang(40051)

        for count, item in enumerate(pack_info, 1):
            try:
                cm = []
                name = item['path']
                if name.startswith('/'):
                    name = name.split('/')[-1]

                url_link = item['url_link']
                if url_link.startswith('/'):
                    url_link = 'http' + url_link

                size = float(int(item['bytes'])) / 1073741824
                label = '%02d | [B]%s[/B] | %.2f GB | [I]%s [/I]' % (
                    count, file_str, size, name)

                url = '%s?action=playURL&url=%s&caller=realdebrid&type=unrestrict' % (
                    sysaddon, url_link)

                cm.append((
                    downloadMenu,
                    'RunPlugin(%s?action=download&name=%s&image=%s&url=%s&caller=realdebrid&type=unrestrict)'
                    % (sysaddon, quote_plus(name), quote_plus(rd_icon),
                       url_link)))
                cm.append((
                    deleteMenu % 'Torrent',
                    'RunPlugin(%s?action=rd_DeleteUserTorrent&id=%s&name=%s)' %
                    (sysaddon, item['id'], quote_plus(name))))

                item = control.item(label=label)
                item.addContextMenuItems(cm)
                item.setArt({
                    'icon': rd_icon,
                    'poster': rd_icon,
                    'thumb': rd_icon,
                    'fanart': addonFanart,
                    'banner': rd_icon
                })
                item.setInfo(type='video', infoLabels='')
                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=False)
            except:
                log_utils.error()
                pass
        control.content(syshandle, 'files')
        control.directory(syshandle, cacheToDisc=True)
Пример #52
0
	def addMenuItem(self, name, action, subid, iconimage, fanart, description='', isFolder=True):
		u = sys.argv[0] + "?action=" + action + "&subid=" + subid
		liz = control.item(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
		liz.setInfo(type='video', infoLabels={'title': name, 'plot': description})
		liz.setProperty('Fanart_Image', fanart)
		control.addItem(handle=syshandle, url=u, listitem=liz, isFolder=isFolder)
Пример #53
0
    def tvshowDirectory(self, items):
        if items == None or len(items) == 0: control.idle() ; sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

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

        traktCredentials = trakt.getTraktCredentialsInfo()

        try: isOld = False ; control.item().getArt('type')
        except: isOld = True

        indicators = playcount.getTVShowIndicators(refresh=True) if action == 'tvshows' else playcount.getTVShowIndicators()

        flatten = True if control.setting('flatten.tvshows') == 'true' else False

        watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8')

        unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8')

        queueMenu = control.lang(32065).encode('utf-8')

        traktManagerMenu = control.lang(32070).encode('utf-8')

        nextMenu = control.lang(32053).encode('utf-8')

        playRandom = control.lang(32535).encode('utf-8')

        addToLibrary = control.lang(32551).encode('utf-8')

        for i in items:
            try:
                label = i['title']
                systitle = sysname = urllib.quote_plus(i['originaltitle'])
                sysimage = urllib.quote_plus(i['poster'])
                imdb, tvdb, year = i['imdb'], i['tvdb'], i['year']

                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb})
                meta.update({'tvdb_id': tvdb})
                meta.update({'mediatype': 'tvshow'})
                meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(label))})
                if not 'duration' in i: meta.update({'duration': '60'})
                elif i['duration'] == '0': meta.update({'duration': '60'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)})
                except: pass

                try:
                    overlay = int(playcount.getTVShowOverlay(indicators, tvdb))
                    if overlay == 7: meta.update({'playcount': 1, 'overlay': 7})
                    else: meta.update({'playcount': 0, 'overlay': 6})
                except:
                    pass


                if flatten == True:
                    url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb)
                else:
                    url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb)


                cm = []

                cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=season&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, urllib.quote_plus(systitle), urllib.quote_plus(year), urllib.quote_plus(imdb), urllib.quote_plus(tvdb))))

                cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

                cm.append((watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, imdb, tvdb)))

                cm.append((unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, imdb, tvdb)))

                if traktCredentials == True:
                    cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb)))

                if isOld == True:
                    cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))

                cm.append((addToLibrary, 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tvdb)))

                item = control.item(label=label)

                art = {}

                if 'poster' in i and not i['poster'] == '0':
                    art.update({'icon': i['poster'], 'thumb': i['poster'], 'poster': i['poster']})
                #elif 'poster2' in i and not i['poster2'] == '0':
                    #art.update({'icon': i['poster2'], 'thumb': i['poster2'], 'poster': i['poster2']})
                else:
                    art.update({'icon': addonPoster, 'thumb': addonPoster, 'poster': addonPoster})

                if 'banner' in i and not i['banner'] == '0':
                    art.update({'banner': i['banner']})
                #elif 'banner2' in i and not i['banner2'] == '0':
                    #art.update({'banner': i['banner2']})
                elif 'fanart' in i and not i['fanart'] == '0':
                    art.update({'banner': i['fanart']})
                else:
                    art.update({'banner': addonBanner})

                if 'clearlogo' in i and not i['clearlogo'] == '0':
                    art.update({'clearlogo': i['clearlogo']})

                if 'clearart' in i and not i['clearart'] == '0':
                    art.update({'clearart': i['clearart']})

                if settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0':
                    item.setProperty('Fanart_Image', i['fanart'])
                #elif settingFanart == 'true' and 'fanart2' in i and not i['fanart2'] == '0':
                    #item.setProperty('Fanart_Image', i['fanart2'])
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

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

                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)

                control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
            except:
                pass

        try:
            url = items[0]['next']
            if url == '': raise Exception()

            icon = control.addonNext()
            url = '%s?action=tvshowPage&url=%s' % (sysaddon, urllib.quote_plus(url))

            item = control.item(label=nextMenu)

            item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon})
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)

            control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True)
        except:
            pass

        control.content(syshandle, 'tvshows')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('tvshows', {'skin.estuary': 55, 'skin.confluence': 500})
Пример #54
0
	def addSectionItem(self, name, iconimage, fanart):
		u = sys.argv[0] + "?action=sectionItem"
		liz = control.item(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
		liz.setProperty('Fanart_Image', fanart)
		control.addItem(handle=syshandle, url=u, listitem=liz, isFolder=False)
Пример #55
0
    def play(self, url, content=None):
        try:
            base = url

            url = resolver().get(url)
            if url == False: return

            control.execute('ActivateWindow(busydialog)')
            url = resolver().process(url)
            control.execute('Dialog.Close(busydialog)')

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

            meta = {}
            for i in [
                    'title', 'originaltitle', 'tvshowtitle', 'year', 'season',
                    'episode', 'genre', 'rating', 'votes', 'director',
                    'writer', 'plot', 'tagline'
            ]:
                try:
                    meta[i] = control.infoLabel('listitem.%s' % i)
                except:
                    pass
            meta = dict((k, v) for k, v in meta.iteritems() if not v == '')
            if not 'title' in meta:
                meta['title'] = control.infoLabel('listitem.label')
            icon = control.infoLabel('listitem.icon')

            self.name = meta['title']
            self.year = meta['year'] if 'year' in meta else '0'

            self.getbookmark = True if (content == 'movies'
                                        or content == 'episodes') else False

            self.offset = bookmarks().get(self.name, self.year)

            f4m = resolver().f4m(url, self.name)
            if not f4m == None: return

            item = control.item(path=url, iconImage=icon, thumbnailImage=icon)
            try:
                item.setArt({'icon': icon})
            except:
                pass
            item.setInfo(type='Video', infoLabels=meta)
            control.player.play(url, item)
            control.resolve(int(sys.argv[1]), True, item)

            self.totalTime = 0
            self.currentTime = 0

            for i in range(0, 240):
                if self.isPlayingVideo(): break
                control.sleep(1000)
            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()
                except:
                    pass
                control.sleep(2000)
            control.sleep(5000)
        except:
            pass
Пример #56
0
	def addSearchItem(self, name, search_id, icon, fanart):
		work_url = "plugin://plugin.video.youtube/kodion/search/query/?q=%s" % search_id
		liz = control.item(name)
		liz.setInfo( type='video', infoLabels={'title': name})
		liz.setArt({'thumb': icon, 'banner': 'DefaultVideo.png', 'fanart': fanart})
		control.addItem(handle=syshandle, url=work_url, listitem=liz, isFolder=True)
Пример #57
0
    def scrape(self, url):
        url = urlparse.urljoin(self.base_main_link, url)
        items = []

        try:
            html = client.request(url, timeout=10)
            item_list = client.parseDOM(
                html,
                'div',
                attrs={'class': 'item col-lg-3 col-md-3 col-sm-12 '})
            for content in item_list:
                link = re.compile('href="(.+?)"',
                                  re.DOTALL).findall(content)[0]
                icon, title = re.compile('img src="(.+?)" alt="(.+?)"',
                                         re.DOTALL).findall(content)[0]
                try:
                    link = link.replace(self.base_main_link, '')
                    title = utils.convert(title).encode('utf-8')

                    item = control.item(label=title)
                    item.setArt({"thumb": icon, "icon": icon})

                    if 'videos_categories' in link:
                        # Still navigating categories
                        link = '%s?action=b98RabbitNav&url=%s' % (sysaddon,
                                                                  link)
                        items.append((link, item, True))
                    else:
                        # This is where the goodies are
                        item.setInfo(type="video",
                                     infoLabels={
                                         "Title": title,
                                         "mediatype": "video"
                                     })
                        item.setProperty("IsPlayable", "true")
                        link = '%s?action=b98CarrotLink&url=%s&title=%s&image=%s' % (
                            sysaddon, link, title, icon)
                        items.append((link, item, False))
                except Exception:
                    failure = traceback.format_exc()
                    log_utils.log('B98 - Failed to Build: \n' + str(failure))
                    continue

            # Try doing a next hole, if available
            try:
                navi_link = re.compile(
                    'a class="next page-numbers" href="(.+?)"',
                    re.DOTALL).findall(html)[0]
                navi_link = navi_link.replace(self.base_main_link, '')
                next_url = '%s?action=b98RabbitNav&url=%s' % (sysaddon,
                                                              navi_link)
                item = control.item(label=control.lang(32053).encode('utf-8'))
                item.setArt({
                    "thumb": control.addonNext(),
                    "icon": control.addonNext()
                })
                items.append((next_url, item, True))
            except Exception:
                pass
        except Exception:
            pass
        control.addItems(syshandle, items)
        self.endDirectory(category='B98 Cartoons')
Пример #58
0
	def addPlaylistItem(self, name, playlist_id, icon, fanart):
		work_url = "plugin://plugin.video.youtube/playlist/%s/" % playlist_id
		liz = control.item(name)
		liz.setInfo( type='video', infoLabels={'title': name})
		liz.setArt({'thumb': icon, 'banner': 'DefaultVideo.png', 'fanart': fanart})
		control.addItem(handle=syshandle, url=work_url, listitem=liz, isFolder=True)
Пример #59
0
    def addItem(self, title, year, imdb, tvdb, season, episode, tvshowtitle,
                premiered, meta):
        try:
            if 'super.fav' in control.infoLabel('Container.PluginName'):
                return control.dialog.ok('Exodus',
                                         control.lang(30518).encode('utf-8'),
                                         '', '')

            self.sources = self.getSources(title, year, imdb, tvdb, season,
                                           episode, tvshowtitle, premiered)
            if self.sources == []: raise Exception()

            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0,
                                       control.lang(30515).encode('utf-8'),
                                       str(' '))

            content = 'movies' if tvshowtitle == None else 'episodes'

            trailerMenu = control.lang(30516).encode(
                'utf-8') if tvshowtitle == None else control.lang(
                    30517).encode('utf-8')

            infoMenu = control.lang(30502).encode(
                'utf-8') if tvshowtitle == None else control.lang(
                    30503).encode('utf-8')

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

            meta = json.loads(meta)

            try:
                del meta['duration']
            except:
                pass

            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()

            systitle = urllib.quote_plus(
                '%s (%s)' % (title, year) if tvshowtitle == None or season ==
                None or episode == None else '%s S%02dE%02d' %
                (tvshowtitle, int(season), int(episode)))
            sysname = urllib.quote_plus(
                '%s (%s)' % (title, year) if tvshowtitle == None or season ==
                None or episode == None else tvshowtitle)
            sysimage, sysaddon = urllib.quote_plus(poster), sys.argv[0]

            for i in range(len(self.sources)):
                try:
                    #if self.progressDialog.iscanceled(): break

                    self.progressDialog.update(
                        int((100 / float(len(self.sources))) * i))

                    label = self.sources[i]['label']

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

                    url = '%s?action=playItem&source=%s' % (sysaddon,
                                                            syssource)

                    cm = []
                    cm.append((control.lang(30504).encode('utf-8'),
                               'RunPlugin(%s?action=queueItem)' % sysaddon))

                    if downloads == True:
                        cm.append((control.lang(30505).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)'
                                   %
                                   (sysaddon, systitle, sysimage, syssource)))

                    cm.append(
                        (trailerMenu, 'RunPlugin(%s?action=trailer&name=%s)' %
                         (sysaddon, sysname)))
                    cm.append((infoMenu, 'Action(Info)'))
                    cm.append((control.lang(30506).encode('utf-8'),
                               'RunPlugin(%s?action=refresh)' % sysaddon))
                    cm.append((control.lang(30507).encode('utf-8'),
                               'RunPlugin(%s?action=openSettings)' % sysaddon))
                    cm.append((control.lang(30508).encode('utf-8'),
                               'RunPlugin(%s?action=openPlaylist)' % sysaddon))

                    item = control.item(label=label,
                                        iconImage='DefaultVideo.png',
                                        thumbnailImage=thumb)
                    try:
                        item.setArt({
                            'poster': poster,
                            'tvshow.poster': poster,
                            'season.poster': poster,
                            'banner': banner,
                            'tvshow.banner': banner,
                            'season.banner': banner
                        })
                    except:
                        pass
                    item.setInfo(type='Video', infoLabels=meta)
                    if not fanart == None:
                        item.setProperty('Fanart_Image', fanart)
                    item.setProperty('Video', 'true')
                    item.addContextMenuItems(cm, replaceItems=True)
                    control.addItem(handle=int(sys.argv[1]),
                                    url=url,
                                    listitem=item,
                                    isFolder=False)
                except:
                    pass

            control.content(int(sys.argv[1]), content)
            control.directory(int(sys.argv[1]), cacheToDisc=True)
            try:
                self.progressDialog.close()
            except:
                pass
        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            try:
                self.progressDialog.close()
            except:
                pass
Пример #60
0
    def seasonDirectory(self, items):
        if not items:
            control.hide()
            control.notification(title=32054, message=33049)
            sys.exit()

        sysaddon = sys.argv[0]
        syshandle = int(sys.argv[1])
        is_widget = 'plugin' not in control.infoLabel('Container.PluginName')
        settingFanart = control.setting('fanart')
        addonPoster = control.addonPoster()
        addonFanart = control.addonFanart()
        addonBanner = control.addonBanner()

        try:
            indicators = playcount.getSeasonIndicators(items[0]['imdb'],
                                                       refresh=True)
        except:
            indicators = None
        unwatchedEnabled = control.setting(
            'tvshows.unwatched.enabled') == 'true'

        if trakt.getTraktIndicatorsInfo():
            watchedMenu = control.lang(32068)
            unwatchedMenu = control.lang(32069)
        else:
            watchedMenu = control.lang(32066)
            unwatchedMenu = control.lang(32067)

        traktManagerMenu = control.lang(32070)
        queueMenu = control.lang(32065)
        showPlaylistMenu = control.lang(35517)
        clearPlaylistMenu = control.lang(35516)
        labelMenu = control.lang(32055)
        playRandom = control.lang(32535)
        addToLibrary = control.lang(32551)

        try:
            multi = [i['tvshowtitle'] for i in items]
        except:
            multi = []
        multi = len([x for y, x in enumerate(multi) if x not in multi[:y]])
        multi = True if multi > 1 else False

        if self.disable_fanarttv != 'true':
            tvdb = [i['tvdb'] for i in items][0]
            from resources.lib.indexers import fanarttv
            extended_art = cache.get(fanarttv.get_tvshow_art, 168, tvdb)
        else:
            extended_art = None

        for i in items:
            try:
                imdb, tmdb, tvdb, year, season = i.get('imdb', '0'), i.get(
                    'tmdb', '0'), i.get('tvdb', '0'), i.get('year',
                                                            '0'), i['season']
                title = i['tvshowtitle']
                label = '%s %s' % (labelMenu, i['season'])

                if not self.season_special and control.setting(
                        'tv.specials') == 'true':
                    self.season_special = True if int(season) == 0 else False
                try:
                    if i['unaired'] == 'true':
                        label = '[COLOR %s][I]%s[/I][/COLOR]' % (
                            self.unairedcolor, label)
                except:
                    pass

                systitle = quote_plus(title)
                meta = dict((k, v) for k, v in i.iteritems() if v != '0')
                meta.update({
                    'code': imdb,
                    'imdbnumber': imdb,
                    'mediatype': 'tvshow',
                    'tag': [imdb, tvdb]
                })

                # Some descriptions have a link at the end that. Remove it.
                try:
                    plot = meta['plot']
                    index = plot.rfind('See full summary')
                    if index >= 0: plot = plot[:index]
                    plot = plot.strip()
                    if re.match(r'[a-zA-Z\d]$', plot): plot += ' ...'
                    meta['plot'] = plot
                except:
                    pass

                try:
                    meta.update({'duration': str(int(meta['duration']) * 60)})
                except:
                    pass
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass
                try:
                    meta.update({'tvshowtitle': i['label']})
                except:
                    pass

                try:
                    # Year is the shows year, not the seasons year. Extract the correct year from the premier date.
                    yearNew = re.findall(r'(\d{4})', i['premiered'])[0]
                    yearNew = yearNew.encode('utf-8')
                    meta.update({'year': yearNew})
                except:
                    pass

                # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster.
                poster = meta.get('thumb') or meta.get('poster3') or meta.get(
                    'poster2') or poster1 or addonPoster
                fanart = ''
                if settingFanart:
                    fanart = meta.get('fanart3') or meta.get(
                        'fanart2') or meta.get('fanart') or addonFanart
                thumb = meta.get('thumb') or poster
                icon = meta.get('icon') or poster
                banner = meta.get('banner3') or meta.get(
                    'banner2') or meta.get('banner') or addonBanner
                if extended_art:
                    clearlogo = extended_art.get('clearlogo')
                    clearart = extended_art.get('clearart')
                else:
                    clearlogo = '0'
                    clearart = '0'
                art = {}
                art.update({
                    'poster': poster,
                    'tvshow.poster': poster,
                    'season.poster': poster,
                    'fanart': fanart,
                    'icon': icon,
                    'thumb': thumb,
                    'banner': banner,
                    'clearlogo': clearlogo,
                    'clearart': clearart
                })

                ####-Context Menu and Overlays-####
                cm = []
                if self.traktCredentials:
                    cm.append((
                        traktManagerMenu,
                        'RunPlugin(%s?action=tools_traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)'
                        % (sysaddon, systitle, imdb, tvdb, season)))

                try:
                    overlay = int(
                        playcount.getSeasonOverlay(indicators, imdb, tvdb,
                                                   season))
                    watched = overlay == 7
                    if watched:
                        meta.update({'playcount': 1, 'overlay': 7})
                        cm.append((
                            unwatchedMenu,
                            'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=6)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                    else:
                        meta.update({'playcount': 0, 'overlay': 6})
                        cm.append((
                            watchedMenu,
                            'RunPlugin(%s?action=playcount_TVShow&name=%s&imdb=%s&tvdb=%s&season=%s&query=7)'
                            % (sysaddon, systitle, imdb, tvdb, season)))
                except:
                    pass

                url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&season=%s' % (
                    sysaddon, systitle, year, imdb, tmdb, tvdb, season)
                cm.append((
                    playRandom,
                    'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s)'
                    % (sysaddon, systitle, year, imdb, tvdb, season)))

                cm.append((queueMenu,
                           'RunPlugin(%s?action=playlist_QueueItem&name=%s)' %
                           (sysaddon, systitle)))
                cm.append((showPlaylistMenu,
                           'RunPlugin(%s?action=playlist_Show)' % sysaddon))
                cm.append((clearPlaylistMenu,
                           'RunPlugin(%s?action=playlist_Clear)' % sysaddon))
                cm.append((
                    addToLibrary,
                    'RunPlugin(%s?action=library_tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s)'
                    % (sysaddon, systitle, year, imdb, tmdb, tvdb)))
                cm.append(
                    ('[COLOR red]Venom Settings[/COLOR]',
                     'RunPlugin(%s?action=tools_openSettings)' % sysaddon))
                ####################################

                if not i.get('trailer'):
                    meta.update({
                        'trailer':
                        '%s?action=trailer&type=%s&name=%s&year=%s&imdb=%s' %
                        (sysaddon, 'show', quote_plus(title), year, imdb)
                    })

                item = control.item(label=label)
                if 'castandart' in i: item.setCast(i['castandart'])
                if 'episodeIDS' in i: item.setUniqueIDs(i['episodeIDS'])
                if unwatchedEnabled:
                    count = playcount.getSeasonCount(imdb, season,
                                                     self.season_special)
                    if count:
                        item.setProperty('TotalEpisodes', str(count['total']))
                        item.setProperty('WatchedEpisodes',
                                         str(count['watched']))
                        item.setProperty('UnWatchedEpisodes',
                                         str(count['unwatched']))

                if 'total_seasons' in meta:
                    item.setProperty('TotalSeasons',
                                     str(meta.get('total_seasons')))

                item.setArt(art)
                item.setProperty('IsPlayable', 'false')
                if is_widget:
                    item.setProperty('isVenom_widget', 'true')
                item.setInfo(type='video',
                             infoLabels=control.metadataClean(meta))
                item.addContextMenuItems(cm)
                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)
                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=True)
            except:
                log_utils.error()

        try:
            control.property(syshandle, 'showplot', items[0]['plot'])
        except:
            pass

        control.content(syshandle, 'seasons')
        control.directory(syshandle, cacheToDisc=True)
        views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})