示例#1
0
    def run(self, url, selectGame ,side):

        if selectGame == None or side == None:
            return control.resolve(int(sys.argv[1]), True, control.item(path=url))

        command = ['java','-jar',jarFile,selectGame,side]

        startupinfo = None
        if os.name == 'nt':
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

        self.process = subprocess.Popen(command,
            stdout=subprocess.PIPE,
            stderr=subprocess.STDOUT,
            startupinfo=startupinfo)

        if os.name == 'posix':
            success = False
            success, output = FuckNeulionClient.request_proxy_hack(selectGame,side)

        control.sleep(1000)

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

        for i in range(0, 240):
            if self.isPlayingVideo(): break
            control.sleep(1000)
        while self.isPlayingVideo():
            control.sleep(1000)
        control.sleep(5000)
示例#2
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
示例#3
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.libraries import views
            views.setView(content, {})
        except:
            return
示例#4
0
 def addDirectoryItem(self,
                      name,
                      query,
                      thumb,
                      icon,
                      context=None,
                      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
     if "http" not in thumb:
         thumb = os.path.join(artPath,
                              thumb) if not artPath == None else icon
     cm = []
     if queue == True:
         cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))
     if not context == None:
         cm.append((control.lang(context[0]).encode('utf-8'),
                    'RunPlugin(%s?action=%s)' % (sysaddon, context[1])))
     item = control.item(label=name)
     item.addContextMenuItems(cm)
     item.setArt({'icon': icon, 'thumb': thumb})
     if not addonFanart == None:
         item.setProperty('Fanart_Image', addonFanart)
     control.addItem(handle=syshandle,
                     url=url,
                     listitem=item,
                     isFolder=isFolder)
示例#5
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=name,
                                iconImage=icon,
                                thumbnailImage=icon,
                                path=url)
            item.setInfo(type="Video", infoLabels={"Title": name})

            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:
            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/phstreams/' + 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 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)
示例#8
0
    def run(self, title, year, season, episode, imdb, tvdb, url, meta):
        try:
            control.sleep(200)

            self.totalTime = 0 ; self.currentTime = 0

            self.content = 'movie' if season == None or episode == None else 'episode'

            self.title = title ; self.year = year
            self.name = urllib.quote_plus(title) + urllib.quote_plus(' (%s)' % year) if self.content == 'movie' else urllib.quote_plus(title) + urllib.quote_plus(' S%02dE%02d' % (int(season), int(episode)))
            self.name = urllib.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.DBID = None
            self.imdb = imdb if not imdb == None else '0'
            self.tvdb = tvdb if not tvdb == None else '0'
            self.ids = {'imdb': self.imdb, 'tvdb': self.tvdb}
            self.ids = dict((k,v) for k, v in self.ids.iteritems() if not v == '0')

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

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

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

            if 'plugin' in control.infoLabel('Container.PluginName'):
                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
示例#9
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)
示例#10
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)
示例#11
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.bennu_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)