Example #1
0
def movie_detail(url_link):
    detail = HighPorn.detail(url_link)
    data = get_movie_detail_json(detail)
    if not data:
        return
    actor_str = ""
    for (count, c) in enumerate(data['actors']):
        if count != len(data['actors']) - 1:
            actor_str = actor_str + c + "/"
        else:
            actor_str = actor_str + c
    yield {
        'label': "Playlist",
        'icon': ADDON_PATH + "/resources/media/playlist.png",
        'path': plugin.url_for("episode_list", url_link=url_link)
    }
    yield ListItem.from_dict(
        **{
            'label': "Poster",
            'icon': ADDON_PATH + "/resources/media/image.png",
            'path': plugin.url_for("image_fanart", img_url=data['poster'])
        })
    yield ListItem.from_dict(
        **{
            'label': "Actor",
            'icon': ADDON_PATH + "/resources/media/actors.png",
            'path': plugin.url_for("actor_list", actors=actor_str),
        })
    yield ListItem.from_dict(
        **{
            'label': "Categories",
            'icon': ADDON_PATH + "/resources/media/category.png",
            'path': plugin.url_for("category_list", category=data['genre']),
        })
Example #2
0
def movie_list(params):
    params = params.split("|")
    if len(params) > 1:
        html = HighPorn.search(params[0], params[1])
    else:
        html = HighPorn.search(params[0])
    data = get_search_result_json(html)
    if not data:
        return
    item = ListItem.from_dict(
        **{
            'label': colorize("Home", "yellow"),
            'icon': ADDON_PATH + "/resources/media/home.png",
            'path': plugin.url_for("index"),
            'is_playable': False
        })
    yield item
    for video in data['video_list']:
        item = ListItem.from_dict(
            **{
                'label': video['title'],
                'icon': video['image'],
                'path': plugin.url_for("movie_detail", url_link=video['link']),
                'is_playable': False
            })
        yield item
    for page in data['page_list']:
        item = ListItem.from_dict(
            **{
                'label': page['name'],
                'path': plugin.url_for("movie_list", params=page['keywords']),
                'is_playable': False
            })
        yield item
Example #3
0
def play(url):
    if url.find('linkOut') != -1:
        urlout = url.split('?id=')[-1]
        url = base64.b64decode(urlout)
        plugin.notify(msg=urlout, title=url)
    resolved = ''
    stream_url = ''
    item = None
    try:
        import urlresolver
        resolved = urlresolver.HostedMediaFile(url).resolve()
        if not resolved or resolved == False or len(resolved) < 1:
            resolved = urlresolver.resolve(url)
            if resolved is None or len(resolved) < 1:
                resolved = urlresolver.resolve(urllib.unquote(url))
        if len(resolved) > 1:
            plugin.notify(msg="PLAY {0}".format(resolved.partition('.')[-1]), title="URLRESOLVER", delay=1000)
            plugin.set_resolved_url(resolved)
            item = ListItem.from_dict(path=resolved)
            item.add_stream_info('video', stream_values={})
            item.set_is_playable(True)
            plugin.play_video(item)
            return None
    except:
        resolved = ''
        plugin.notify(msg="FAILED {0}".format(url.partition('.')[-1]), title="URLRESOLVER", delay=1000)
    try:
        import YDStreamExtractor
        info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True)
        resolved = info.streamURL()
        for s in info.streams():
            try:
                stream_url = s['xbmc_url'].encode('utf-8', 'ignore')
                xbmc.log(msg="**YOUTUBE-DL Stream found: {0}".format(stream_url))
            except:
                pass
        if len(stream_url) > 1:
            resolved = stream_url
        if len(resolved) > 1:
            plugin.notify(msg="Playing: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
            plugin.set_resolved_url(resolved)
            item = ListItem.from_dict(path=resolved)
            item.add_stream_info('video', stream_values={})
            item.set_is_playable(True)
            plugin.play_video(item)
            return None
    except:
        plugin.notify(msg="Failed: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
    if len(resolved) > 1:
        plugin.set_resolved_url(resolved)
        item = ListItem.from_dict(path=resolved)
        plugin.play_video(item)
        return None
    else:
        plugin.set_resolved_url(url)
        plugin.play_video(url)
        return None
Example #4
0
def play(url):
    resolved = ''
    stream_url = ''
    item = None
    try:
        import urlresolver
        resolved = urlresolver.HostedMediaFile(url).resolve()
        if not resolved or resolved == False or len(resolved) < 1:
            resolved = urlresolver.resolve(url)
            if resolved is None or len(resolved) < 1:
                resolved = urlresolver.resolve(urllib.unquote(url))
        if len(resolved) > 1:
            plugin.notify(msg="PLAY {0}".format(resolved.partition('.')[-1]), title="URLRESOLVER", delay=1000)
            plugin.set_resolved_url(resolved)
            item = ListItem.from_dict(path=resolved)
            item.add_stream_info('video', stream_values={})
            item.set_is_playable(True)
            return item
    except:
        resolved = ''
        plugin.notify(msg="FAILED {0}".format(url.partition('.')[-1]), title="URLRESOLVER", delay=1000)
    try:
        import YDStreamExtractor
        info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True)
        resolved = info.streamURL()
        for s in info.streams():
            try:
                stream_url = s['xbmc_url'].encode('utf-8', 'ignore')
                xbmc.log(msg="**YOUTUBE-DL Stream found: {0}".format(stream_url))
            except:
                pass
        if len(stream_url) > 1:
            resolved = stream_url
        if len(resolved) > 1:
            plugin.notify(msg="Playing: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
            plugin.set_resolved_url(resolved)
            item = ListItem.from_dict(path=resolved)
            item.add_stream_info('video', stream_values={})
            item.set_is_playable(True)
            return item
    except:
        plugin.notify(msg="Failed: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)

    if len(resolved) > 1:
        plugin.set_resolved_url(resolved)
        item = ListItem.from_dict(path=resolved)
        return item
    else:
        plugin.set_resolved_url(url)  # url)
        # plugurl = 'plugin://plugin.video.live.streamspro/?url={0}'.format(urllib.quote_plus(url))
        # item = ListItem.from_dict(path=plugurl)
        # item.add_stream_info('video', stream_values={})
        # item.set_is_playable(True)
        # plugin.notify(msg="RESOLVE FAIL: {0}".format(url.split('.', 1)[-1]),title="Trying {0}".format(item.path.split('.', 1)[-1]), delay=2000)
        return None
Example #5
0
    def test_from_dict_props(self):
        dct = {
            'properties': {'StartOffset': '256.4'},
        }
        item = ListItem.from_dict(**dct)
        self.assertEqual(item.get_property('StartOffset'), '256.4')

        dct = {
            'properties': [('StartOffset', '256.4')],
        }
        item = ListItem.from_dict(**dct)
        self.assertEqual(item.get_property('StartOffset'), '256.4')
Example #6
0
    def test_from_dict_props(self):
        dct = {
            'properties': {'StartOffset': '256.4'},
        }
        item = ListItem.from_dict(**dct)
        self.assertEqual(item.get_property('StartOffset'), '256.4')

        dct = {
            'properties': [('StartOffset', '256.4')],
        }
        item = ListItem.from_dict(**dct)
        self.assertEqual(item.get_property('StartOffset'), '256.4')
Example #7
0
def play(url):
    if plugin.get_setting('debugon', converter=bool): web_pdb.set_trace()

    resolved = ''
    stream_url = ''
    item = None
    try:
        import urlresolver
        resolved = urlresolver.HostedMediaFile(url).resolve()
        if not resolved or resolved == False or len(resolved) < 1:
            resolved = urlresolver.resolve(url)
            if resolved is None or len(resolved) < 1:
                resolved = urlresolver.resolve(WebUtils.unescape(url))
        if len(resolved) > 1:
            plugin.notify(msg="PLAY {0}".format(resolved.partition('.')[-1]), title="URLRESOLVER", delay=1000)
            plugin.set_resolved_url(resolved)
            item = ListItem.from_dict(path=resolved)
            item.add_stream_info('video', stream_values={})
            item.set_is_playable(True)
            return item
    except:
        resolved = ''
        plugin.notify(msg="FAILED {0}".format(url.partition('.')[-1]), title="URLRESOLVER", delay=1000)
    try:
        import YDStreamExtractor
        info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True)
        resolved = info.streamURL()
        for s in info.streams():
            try:
                stream_url = s['xbmc_url'].encode('utf-8', 'ignore')
                xbmc.log(msg="**YOUTUBE-DL Stream found: {0}".format(stream_url))
            except:
                pass
        if len(stream_url) > 1:
            resolved = stream_url
        if len(resolved) > 1:
            plugin.notify(msg="Playing: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)
            plugin.set_resolved_url(resolved)
            item = ListItem.from_dict(path=resolved)
            item.add_stream_info('video', stream_values={})
            item.set_is_playable(True)
            return item
    except:
        plugin.notify(msg="Failed: {0}".format(resolved.partition('.')[-1]), title="YOUTUBE-DL", delay=1000)

    if len(resolved) > 1:
        plugin.set_resolved_url(resolved)
        item = ListItem.from_dict(path=resolved)
        return item
    else:
        plugin.set_resolved_url(url)  # url)
        return None
Example #8
0
 def test_from_dict_info_default_info_type(self):
     dct = {'info': {'title': 'My title'}}
     # noinspection PyUnresolvedReferences
     with mock.patch.object(ListItem, 'set_info',
                            spec=False) as mock_set_info:
         _ = ListItem.from_dict(**dct)
     mock_set_info.assert_called_with('video', {'title': 'My title'})
Example #9
0
def loadsaved():
    sitems = []
    litems = []
    items = []
    savedpath = ''
    try:
        savedpath = path.join(__datadir__, "saved.json")
        if path.exists(savedpath):
            fpin = file(savedpath)
            rawjson = fpin.read()
            sitems = json.loads(rawjson)
            fpin.close()
        else:
            return []
        for item in sitems:
            li = ListItem.from_dict(**item)
            li.add_context_menu_items([(
                'Remove Saved Show',
                'RunPlugin("{0}")'.format(
                    plugin.url_for(removeshow, name=li.label, link=li.path)),
            )])
            litems.append(li)
    except:
        pass
    return litems
Example #10
0
 def test_from_dict_info_default_info_type(self):
     dct = {'info': {'title': 'My title'}}
     # noinspection PyUnresolvedReferences
     with mock.patch.object(ListItem, 'set_info',
                            spec=False) as mock_set_info:
         _ = ListItem.from_dict(**dct)
     mock_set_info.assert_called_with('video', {'title': 'My title'})
Example #11
0
def episode(name='', url=''):
    waserror = False
    linklist = []
    if len(url) == '':
        waserror = True
    else:
        html = DL(url)
        litems = []
        linklist = findvidlinks(html)
        itemparent = None
    if len(linklist) > 0:
        for name, link in linklist:
            itempath = plugin.url_for(play, url=link)
            item = dict(label=name, label2=link, icon='DefaultFolder.png', thumbnail='DefaultFolder.png', path=itempath)
            item.setdefault(item.keys()[0])
            litems.append(item)
        vitems = sortSourceItems(litems)
        litems = []
        for li in vitems:
            item = ListItem.from_dict(**li)
            item.set_is_playable(True)
            item.set_info(info_type='video', info_labels={'Title': item.label, 'Plot': item.label2})
            item.add_stream_info(stream_type='video', stream_values={})
            litems.append(item)
    else:
        waserror = True
    if waserror:
        plugin.notify(title="ERROR No links: {0}".format(name), msg=url)
        return []
    return litems
Example #12
0
def episode(name=None, url=None):
    if plugin.get_setting('debugon', converter=bool): web_pdb.set_trace()

    waserror = False
    linklist = []
    litems = []
    if len(url) == '':
        waserror = True
    else:
        html = DL(url)
        linklist = ws.findvidlinks(html)
        itemparent = None
    if len(linklist) > 0:
        for name, link in linklist:
            itempath = plugin.url_for(play, url=link)
            item = dict(label=name, label2=link, icon='DefaultFolder.png', thumbnail='DefaultFolder.png', path=itempath)
            item.setdefault(item.keys()[0])
            litems.append(item)
        vitems = ws.sortSourceItems(litems)
        litems = []
        for li in vitems:
            item = ListItem.from_dict(**li)
            item.set_is_playable(True)
            item.set_info(info_type='video', info_labels={'Title': item.label, 'Plot': item.label2})
            item.add_stream_info(stream_type='video', stream_values={})
            litems.append(item)
    else:
        waserror = True
    if waserror:
        plugin.notify(title="ERROR No links: {0}".format(name), msg=url)
        return []
    return litems
Example #13
0
def category_episodemake(episodename, episodelink, dateadded=None):
    '''
    Will return a ListItem for the given link to an episode and it's full linked name.
    Name will be sent to format show to attempt to parse out a date or season from the title.
    Infolabels are populated with any details that can be parsed from the title as well.
    Should be used anytime an item needs to be created that is an item for one specific episode of a show.
    Latest 350, Saved Show, Category (Show listing of all episodes for that series) would all use this.
    '''
    infolbl = {}
    spath = plugin.url_for(episode, name=episodename, url=episodelink)
    if plugin.get_setting('playold', converter=bool):
        spath = spath.replace("plugin.video.watchseries/",
                              "plugin.video.wsonline/")
    img = "DefaultVideoFolder.png"
    seasonstr = ''
    try:
        eptitle, epdate, epnum = ws.formatshow(episodename)
        eplbl = ws.formatlabel(eptitle, epdate, epnum)
        plotstr = "{0} ({1}): {2} {3}".format(epdate, epnum, eptitle,
                                              episodelink)
        infolbl = {'EpisodeName': epdate, 'Title': eptitle, 'Plot': plotstr}
        if len(epnum) > 0:
            showS, showE = ws.findepseason(epnum)
            snum = int(showS)
            epnum = int(showE)
            infolbl.update({'Episode': showE, 'Season': showS})
            if snum > 0 and epnum > 0:
                epdate = "S{0}e{1}".format(snum, epnum)
                infolbl.update({'PlotOutline': epdate})
        if dateadded is not None:
            dateout = str(dateadded.replace(' ', '-')).strip()
            infolbl.update({"Date": dateout})
        item = {
            'label': eplbl,
            'label2': epdate,
            'icon': img,
            'thumbnail': img,
            'path': spath
        }
        item.setdefault(item.keys()[0])
        li = ListItem.from_dict(**item)
        li.set_is_playable(is_playable=True)
        li.is_folder = True
        li.set_info(type='video', info_labels=infolbl)
        li.add_context_menu_items([(
            'Autoplay',
            'RunPlugin("{0}")'.format(
                plugin.url_for(endpoint=ws.func_autoplay, url=episodelink)),
        )])
    except:
        li = ListItem(label=episodename,
                      label2=episodelink,
                      icon=img,
                      thumbnail=img,
                      path=spath)
    return li
Example #14
0
def playfirst(url=''):
    idx = 0
    if len(url) < 1:
        return None
    thispath = plugin.url_for(endpoint=play, url=url)
    selItem = None
    outtxt = "Not Found"
    try:
        for fitem in plugin.added_items:
            if fitem.selected == True or fitem.path.find(thispath) != -1:
                try:
                    plugin.set_resolved_url(fitem)
                    fitem.is_playable(True)
                    fitem.played(True)
                except:
                    pass
                selItem = fitem
                plugin.notify(msg=selItem.label, title="Found item")
                break
    except:
        selItem = None
    if selItem is not None:
        try:
            selItem.set_is_playable(True)
            selItem.set_played(was_played=True)
            outtxt = selItem.label + " " + selItem.label2
        except:
            outtxt = str(repr(selItem))
    plugin.notify(msg=outtxt, title=str(idx))
    html = DL(url)
    prefhost = ''
    sourceslist = []
    stext = plugin.get_setting('topSources')
    if len(stext) < 1:
        prefhost = 'thevideo'
    else:
        sourceslist = stext.split(',')
        prefhost = sourceslist[0]
    litems = []
    linklist = findvidlinks(html, findhost=prefhost)
    if len(linklist) > 0:
        name, link = linklist[0]
        #itempath = plugin.url_for(play, url=link)
        itempath = plugin.url_for(play, url=link)
        sitem = dict(label=name, label2=link, icon='DefaultFolder.png', thumbnail='DefaultFolder.png', path=itempath)
        sitem.setdefault(sitem.keys()[0])
        item = ListItem.from_dict(**sitem)
        item.set_is_playable(True)
        item.set_info(info_type='video', info_labels={'Title': item.label, 'Plot': item.label2})
        item.add_stream_info(stream_type='video', stream_values={})
        plugin.notify(msg=link, title=name)
        #plugin.add_items([item])
        item.set_played(was_played=True)
        #plugin.add_items([plugin.set_resolved_url(link)])#.as_tuple())])
        plugin.play_video(item)
        return [plugin.set_resolved_url(item)]
Example #15
0
def index():
    if not os.path.exists(DB_FILE):
        create_connection()
    item = ListItem.from_dict(
        **{
            'label': colorize("Input Keyword", "yellow"),
            'icon': ADDON_PATH + "/resources/media/search.png",
            'path': plugin.url_for("input_keyword"),
            'is_playable': False
        })
    yield item
    item = ListItem.from_dict(
        **{
            'label': colorize("Video List Library", "yellow"),
            'icon': ADDON_PATH + "/resources/media/library.png",
            'path': plugin.url_for("movie_library"),
            'is_playable': False
        })
    yield item
Example #16
0
def playfirst(url=''):
    idx = 0
    if len(url) < 1:
        return None
    thispath = plugin.url_for(endpoint=play, url=url)
    selItem = None
    outtxt = "Not Found"
    try:
        for fitem in plugin.added_items:
            if fitem.selected == True or fitem.path.find(thispath) != -1:
                try:
                    plugin.set_resolved_url(fitem)
                    fitem.is_playable(True)
                    fitem.played(True)
                except:
                    pass
                selItem = fitem
                plugin.notify(msg=selItem.label, title="Found item")
                break
    except:
        selItem = None
    if selItem is not None:
        try:
            selItem.set_is_playable(True)
            selItem.set_played(was_played=True)
            outtxt = selItem.label + " " + selItem.label2
        except:
            outtxt = str(repr(selItem))
    plugin.notify(msg=outtxt, title=str(idx))
    html = DL(url)
    prefhost = ''
    sourceslist = []
    stext = plugin.get_setting('topSources')
    if len(stext) < 1:
        prefhost = 'thevideo'
    else:
        sourceslist = stext.split(',')
        prefhost = sourceslist[0]
    litems = []
    linklist = findvidlinks(html, findhost=prefhost)
    if len(linklist) > 0:
        name, link = linklist[0]
        itempath = plugin.url_for(play, url=link)
        sitem = dict(label=name, label2=link, icon='DefaultFolder.png', thumbnail='DefaultFolder.png', path=itempath)
        sitem.setdefault(sitem.keys()[0])
        item = ListItem.from_dict(**sitem)
        item.set_is_playable(True)
        item.set_info(type='video', info_labels={'Title': item.label, 'Plot': item.label2})
        item.add_stream_info(stream_type='video', stream_values={})
        plugin.notify(msg=link, title=name)
        #plugin.add_items([item])
        item.set_played(was_played=True)
        #plugin.add_items([plugin.set_resolved_url(link)])#.as_tuple())])
        plugin.play_video(item)
        return [plugin.set_resolved_url(item)]
Example #17
0
def genre_db():
    genre_list = get_genres_db()
    for item in genre_list:
        item = ListItem.from_dict(
            **{
                'label': item,
                'icon': ADDON_PATH + "/resources/media/tag.png",
                'path': plugin.url_for("movie_list", params=item),
                'is_playable': False
            })
        yield item
Example #18
0
def set_video_item(item):
    if not item['url']:
        return None
    listitem = ListItem.from_dict(
        **{
            'label':
            item['desc_japan'] if item['desc_japan'] else item['name'],
            'icon': item['poster'],
            'path': plugin.url_for("movie_detail", url_link=item['url'][19:]),
            'is_playable': False
        })
    return listitem
Example #19
0
def play(url):
    if url.find('linkOut') != -1:
        urlout = url.split('?id=')[-1]
        url = base64.b64decode(urlout)
    resolved = ''
    stream_url = ''
    item = None
    try:
        if urlresolver is not None:
            stream_url = urlresolver.resolve(url)
        if len(stream_url) > 1:
            resolved = stream_url
    except:
        plugin.notify(msg="{0}".format(url),
                      title="URLResolver FAILED",
                      delay=1000)
    if len(resolved) < 1:
        plugin.notify(msg="{0}".format(url),
                      title="Trying YouTube-DL",
                      delay=1000)
        try:
            import YDStreamExtractor
            info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True)
            stream_url = info.streamURL()
            if len(stream_url) < 1 or stream_url.find('http') == -1:
                for s in info.streams():
                    try:
                        stream_url = s['xbmc_url'].encode('utf-8', 'ignore')
                        xbmc.log(msg="**YOUTUBE-DL Stream found: {0}".format(
                            stream_url))
                    except:
                        pass
                if len(stream_url) > 1:
                    resolved = stream_url
            else:
                resolved = stream_url
        except:
            plugin.notify(msg="{0}".format(url),
                          title="YOUTUBE-DL Failed",
                          delay=1000)
    if len(resolved) < 1:
        plugin.notify(msg="{0}".format(url),
                      title="FAILED TO RESOLVE",
                      delay=1000)
        return None
    else:
        vidurl = resolved.encode('utf-8', 'ignore')
        item = ListItem.from_dict(path=vidurl)
        item.add_stream_info('video', stream_values={})
        item.set_is_playable(True)
        plugin.set_resolved_url(item)
        return plugin.play_video(item)
Example #20
0
def makecatitem(name, link, removelink=False):
    item = {}
    ctxitem = {}
    itempath = plugin.url_for(category, name=name, url=link)
    item = {'label': name, 'label2': link, 'icon': 'DefaultFolder.png', 'thumbnail': 'DefaultFolder.png',
            'path': itempath}
    item.setdefault(item.keys()[0])
    litem = ListItem.from_dict(**item)
    # if removelink:
    #    litem.add_context_menu_items([('Remove Saved Show', 'RunPlugin("{0}")'.format(plugin.url_for(removeshow, name=name, link=itempath)),)])
    # else:
    litem.add_context_menu_items(
        [('Save Show', 'RunPlugin("{0}")'.format(plugin.url_for(saveshow, name=name, link=link)),)])
    return litem
Example #21
0
def makecatitem(name, link, removelink=False):
    item = {}
    ctxitem = {}
    itempath = plugin.url_for(category, name=name, url=link)
    item = {'label': name, 'label2': link, 'icon': 'DefaultFolder.png', 'thumbnail': 'DefaultFolder.png',
            'path': itempath}
    item.setdefault(item.keys()[0])
    litem = ListItem.from_dict(**item)
    # if removelink:
    #    litem.add_context_menu_items([('Remove Saved Show', 'RunPlugin("{0}")'.format(plugin.url_for(removeshow, name=name, link=itempath)),)])
    # else:
    litem.add_context_menu_items(
        [('Save Show', 'RunPlugin("{0}")'.format(plugin.url_for(saveshow, name=name, link=link)),)])
    return litem
Example #22
0
def actor_db():
    actor_list = get_actors_db()
    for actor in actor_list:
        if not actor:
            continue
        item = ListItem.from_dict(
            **{
                'label': actor[2] if actor[2] else actor[1],
                'label2': actor[2],
                'icon': actor[4] if actor[4] else ADDON_PATH +
                "/resources/media/actor.png",
                'path': plugin.url_for("movie_list", params=actor[1]),
                'is_playable': False
            })
        yield item
Example #23
0
def video_list_db():
    video_list = get_videos_db()
    item = ListItem.from_dict(
        **{
            'label': colorize("Home", "yellow"),
            'icon': ADDON_PATH + "/resources/media/home.png",
            'path': plugin.url_for("index"),
            'is_playable': False
        })
    yield item
    for video in video_list:
        item = set_video_item(video)
        if not item:
            continue
        yield item
Example #24
0
    def test_from_dict(self):
        dct = {
            'label': 'foo',
            'label2': 'bar',
            'icon': 'icon',
            'thumbnail': 'thumbnail',
            'path': 'plugin://my.plugin.id/',
            'selected': True,
            'info': {
                'title': 'My title'
            },
            'info_type': 'pictures',
            'properties': [('StartOffset', '256.4')],
            'stream_info': {
                'video': {
                    'duration': 185
                }
            },
            'context_menu': [('label', 'action')],
            'is_playable': True
        }

        # noinspection PyUnresolvedReferences
        with mock.patch.object(ListItem, 'set_info',
                               spec=False) as mock_set_info:
            # noinspection PyUnresolvedReferences
            with mock.patch.object(ListItem, 'add_stream_info',
                                   spec=False) as mock_set_stream:
                item = ListItem.from_dict(**dct)

        self.assertEqual(item.label, 'foo')
        self.assertEqual(item.label2, 'bar')
        self.assertEqual(item.icon, 'icon')
        self.assertEqual(item.thumbnail, 'thumbnail')
        self.assertEqual(item.path, 'plugin://my.plugin.id/')
        self.assertEqual(item.selected, True)
        mock_set_info.assert_called_with('pictures', {'title': 'My title'})
        mock_set_stream.assert_called_with('video', {'duration': 185})
        self.assertEqual(item.get_property('StartOffset'), '256.4')
        self.assertEqual(item.get_context_menu_items(), [('label', 'action')])
        self.assertEqual(item.get_property('isPlayable'), 'true')
        self.assertEqual(item.playable, True)
        self.assertEqual(item.is_folder, False)
Example #25
0
def episode_makeitem(episodename, episodelink, dateadded=None):
    '''
    Will return a ListItem for the given link to an episode and it's full linked name.
    Name will be sent to format show to attempt to parse out a date or season from the title.
    Infolabels are populated with any details that can be parsed from the title as well.
    Should be used anytime an item needs to be created that is an item for one specific episode of a show.
    Latest 350, Saved Show, Category (Show listing of all episodes for that series) would all use this.
    '''
    infolbl = {}
    sourcespath = plugin.url_for(episode, name=episodename, url=episodelink)
    img = "DefaultVideoFolder.png"
    seasonstr = ''
    try:
        eptitle, epdate, epnum = formatshow(episodename)
        eplbl = formatlabel(eptitle, epdate, epnum)
        plotstr = "{0} ({1}): {2} {3}".format(epdate, epnum, eptitle, episodelink)
        infolbl = {'EpisodeName': epdate, 'Title': eptitle, 'Plot': plotstr}
        if len(epnum) > 0:
            showS, showE = findepseason(epnum)
            snum = int(showS)
            epnum = int(showE)
            infolbl.update({'Episode': showE, 'Season': showS})
            if snum > 0 and epnum > 0:
                epdate = "S{0}e{1}".format(snum, epnum)
                infolbl.update({'PlotOutline': epdate})
        if dateadded is not None:
            dateout = str(dateadded.replace(' ', '-')).strip()
            infolbl.update({"Date": dateout})
        #sourcespath = plugin.url_for(episode, name=episodename, url=episodelink)
        playpath = plugin.url_for(endpoint=playfirst, url=episodelink)
        item = {'label': eplbl, 'label2': epdate, 'icon': img, 'thumbnail': img, 'path': playpath}
        item.setdefault(item.keys()[0])
        li = ListItem.from_dict(**item)
        li.set_is_playable(is_playable=True)
        li.is_folder = False
        li.set_info(info_type='video', info_labels=infolbl)
        li.add_context_menu_items(
            [('Sources', 'RunPlugin("{0}")'.format(sourcespath),)])
            #[('Autoplay', 'RunPlugin("{0}")'.format(plugin.url_for(endpoint=playfirst, url=episodelink)),)])
    except:
        li = ListItem(label=episodename, label2=episodelink, icon=img, thumbnail=img, path=sourcespath)
    return li
Example #26
0
def search(keyword):
    params = keyword.split("|")
    if not params:
        return
    if len(params) > 1:
        data = HighPorn.search(params[0], params[1])
    else:
        data = HighPorn.search(params[0])
    for item in data:
        link = item.find('a').get('href')
        img_url = item.find('img').get('src')
        img = "http:" + img_url if img_url[:4] != "http" else img_url
        title = item.find('img').get('title')
        item = ListItem.from_dict(
            **{
                'label': title,
                'icon': img,
                'path': plugin.url_for("movie_detail", url_link=link),
                'is_playable': False
            })
        yield item
Example #27
0
def interactive(plugin):
    """A run mode for the CLI that runs the plugin in a loop based on user
    input.
    """
    items = [item for item in once(plugin) if not item.get_played()]
    parent_stack = []  # Keep track of parents so we can have a '..' option

    selected_item = get_user_choice(items)
    while selected_item is not None:
        if parent_stack and selected_item == parent_stack[-1]:
            # User selected the parent item, remove from list
            parent_stack.pop()
        else:
            # User selected non parent item, add current url to parent stack
            parent_stack.append(ListItem.from_dict(label='..',
                                                   path=plugin.request.url))
        patch_plugin(plugin, selected_item.get_path())

        items = [item for item in once(plugin, parent_stack=parent_stack)
                 if not item.get_played()]
        selected_item = get_user_choice(items)
Example #28
0
    def test_from_dict(self):
        dct = {
            'label': 'foo',
            'label2': 'bar',
            'icon': 'icon',
            'thumbnail': 'thumbnail',
            'path': 'plugin://my.plugin.id/',
            'selected': True,
            'info': {'title': 'My title'},
            'info_type': 'pictures',
            'properties': [('StartOffset', '256.4')],
            'stream_info': {
                'video': {'duration': 185}
            },
            'context_menu': [('label', 'action')],
            'is_playable': True}

        # noinspection PyUnresolvedReferences
        with mock.patch.object(ListItem, 'set_info',
                               spec=False) as mock_set_info:
            # noinspection PyUnresolvedReferences
            with mock.patch.object(ListItem, 'add_stream_info',
                                   spec=False) as mock_set_stream:
                item = ListItem.from_dict(**dct)

        self.assertEqual(item.label, 'foo')
        self.assertEqual(item.label2, 'bar')
        self.assertEqual(item.icon, 'icon')
        self.assertEqual(item.thumbnail, 'thumbnail')
        self.assertEqual(item.path, 'plugin://my.plugin.id/')
        self.assertEqual(item.selected, True)
        mock_set_info.assert_called_with('pictures', {'title': 'My title'})
        mock_set_stream.assert_called_with('video', {'duration': 185})
        self.assertEqual(item.get_property('StartOffset'), '256.4')
        self.assertEqual(item.get_context_menu_items(), [('label', 'action')])
        self.assertEqual(item.get_property('isPlayable'), 'true')
        self.assertEqual(item.playable, True)
        self.assertEqual(item.is_folder, True)
Example #29
0
def loadsaved():
    sitems = []
    litems = []
    items = []
    savedpath = ''
    try:
        savedpath = path.join(__datadir__, "saved.json")
        if path.exists(savedpath):
            fpin = file(savedpath)
            rawjson = fpin.read()
            sitems = json.loads(rawjson)
            fpin.close()
        else:
            return []
        for item in sitems:
            li = ListItem.from_dict(**item)
            li.add_context_menu_items(
                [('Remove Saved Show',
                  'RunPlugin("{0}")'.format(plugin.url_for(removeshow, name=li.label, link=li.path)),)])
            litems.append(li)
    except:
        pass
    return litems
Example #30
0
def episode_makeitem(episodename, episodelink, dateadded=None):
    '''
    Will return a ListItem for the given link to an episode and it's full linked name.
    Name will be sent to format show to attempt to parse out a date or season from the title.
    Infolabels are populated with any details that can be parsed from the title as well.
    Should be used anytime an item needs to be created that is an item for one specific episode of a show.
    Latest 350, Saved Show, Category (Show listing of all episodes for that series) would all use this.
    '''
    infolbl = {}
    sourcespath = plugin.url_for(episode, name=episodename, url=episodelink)
    img = "DefaultVideoFolder.png"
    seasonstr = ''
    try:
        eptitle, epdate, epnum = formatshow(episodename)
        eplbl = formatlabel(eptitle, epdate, epnum)
        plotstr = "{0} ({1}): {2} {3}".format(epdate, epnum, eptitle,
                                              episodelink)
        epdate = epdate.strip('-')
        try:
            import dateutil
            asdate = dateutil.parser.parse(epdate)
            premdate = asdate.isoformat().split('T', 1)[0]
        except:
            premdate = "2000-01-01"
        infolbl = {
            'Premiered': premdate,
            'TVShowTitle': eptitle,
            'Plot': plotstr
        }
        if len(epnum) > 0:
            showS, showE = findepseason(epnum)
            snum = int(showS)
            epnum = int(showE)
            infolbl.update({'Episode': showE, 'Season': showS})
            if snum > 0 and epnum > 0:
                epdate = "S{0}e{1}".format(snum, epnum)
                infolbl.update({'PlotOutline': epdate})
        #sourcespath = plugin.url_for(episode, name=episodename, url=episodelink)
        playpath = plugin.url_for(endpoint=playfirst,
                                  url=episodelink.encode('utf-8', 'ignore'))
        item = {
            'label': eplbl,
            'label2': epdate,
            'icon': img,
            'thumbnail': img,
            'path': playpath.encode('utf-8', 'ignore')
        }
        item.setdefault(item.keys()[0])
        li = ListItem.from_dict(**item)
        li.set_is_playable(is_playable=True)
        li.is_folder = False
        li.set_info(info_type='video', info_labels=infolbl)
        #li.add_context_menu_items([('Sources', 'RunPlugin("{0}")'.format(sourcespath),)])
        #[('Autoplay', 'RunPlugin("{0}")'.format(plugin.url_for(endpoint=playfirst, url=episodelink)),)])
    except:
        li = ListItem(label=episodename,
                      label2=episodelink,
                      icon=img,
                      thumbnail=img,
                      path=sourcespath)
    return li
Example #31
0
def playold(url):
    if url.find('linkOut') != -1:
        urlout = url.split('?id=')[-1]
        url = base64.b64decode(urlout)
    resolved = ''
    stream_url = ''
    item = None
    try:
        if urlresolver is not None:
            resolved = urlresolver.resolve(url)
        if len(resolved) > 1:
            plugin.notify(msg="PLAY {0}".format(resolved.split('://', 1)[-1]),
                          title="URLRESOLVER",
                          delay=1000)
            plugin.set_resolved_url(resolved)
            item = ListItem.from_dict(path=resolved)
            item.add_stream_info('video', stream_values={})
            item.set_is_playable(True)
            plugin.play_video(item)
            return None
    except:
        resolved = ''
        plugin.notify(msg="FAILED {0}".format(url),
                      title="URLResolver",
                      delay=1000)
    try:
        import YDStreamExtractor
        info = YDStreamExtractor.getVideoInfo(url, resolve_redirects=True)
        resolved = info.streamURL()
        for s in info.streams():
            try:
                stream_url = s['xbmc_url'].encode('utf-8', 'ignore')
                xbmc.log(
                    msg="**YOUTUBE-DL Stream found: {0}".format(stream_url))
            except:
                pass
        if len(stream_url) > 1:
            resolved = stream_url
        if len(resolved) > 1:
            plugin.notify(msg="PLAY: {0}".format(resolved.split('://', 1)[-1]),
                          title="YOUTUBE-DL",
                          delay=1000)
            plugin.set_resolved_url(resolved)
            item = ListItem.from_dict(path=resolved)
            item.add_stream_info('video', stream_values={})
            item.set_is_playable(True)
            plugin.play_video(item)
            return None
    except:
        plugin.notify(msg="Failed: {0}".format(resolved.partition('.')[-1]),
                      title="YOUTUBE-DL",
                      delay=1000)
    if len(resolved) > 1:
        plugin.set_resolved_url(resolved)
        item = ListItem.from_dict(path=resolved)
        plugin.play_video(item)
        return None
    else:
        plugin.set_resolved_url(url)
        plugin.play_video(url)
        return None