Example #1
0
 def test_set_info(self):
     # noinspection PyUnresolvedReferences
     with mock.patch.object(xbmcgui.ListItem,
                            'setInfo') as mock_setInfo:
         item = ListItem()
         item.set_info('video', {'title': '300'})
     mock_setInfo.assert_called_with('video', {'title': '300'})
Example #2
0
 def test_label(self):
     item = ListItem('foo')
     self.assertEqual(item.label, 'foo')
     item.label = 'bar'
     self.assertEqual(item.label, 'bar')
     item.set_label('baz')
     self.assertEqual(item.get_label(), 'baz')
Example #3
0
 def test_is_selected(self):
     # noinspection PyUnresolvedReferences
     with mock.patch.object(xbmcgui.ListItem, 'isSelected') as mock_selected:
         mock_selected.return_value = False
         item = ListItem()
         self.assertEqual(item.is_selected(), False)
     mock_selected.assert_called_with()
Example #4
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 #5
0
 def test_set_info(self):
     # noinspection PyUnresolvedReferences
     with mock.patch.object(xbmcgui.ListItem,
                            'setInfo') as mock_setInfo:
         item = ListItem()
         item.set_info('video', {'title': '300'})
     mock_setInfo.assert_called_with('video', {'title': '300'})
Example #6
0
 def test_label2(self):
     item = ListItem('foo')
     self.assertIsNone(item.label2)
     item.label2 = 'bar'
     self.assertEqual(item.label2, 'bar')
     item.set_label2('baz')
     self.assertEqual(item.get_label2(), 'baz')
Example #7
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 #8
0
 def test_is_selected(self):
     # noinspection PyUnresolvedReferences
     with mock.patch.object(xbmcgui.ListItem, 'isSelected') as mock_selected:
         mock_selected.return_value = False
         item = ListItem()
         self.assertEqual(item.is_selected(), False)
     mock_selected.assert_called_with()
Example #9
0
    def test_poster(self):
        item = ListItem()
        self.assertIsNone(item.poster)

        item.poster = 'bar'
        self.assertEqual(item.poster, 'bar')
        item.poster = 'baz'
        self.assertEqual(item.poster, 'baz')
Example #10
0
    def test_played(self):
        item = ListItem()
        self.assertEqual(item.played, False)

        item.played = True
        self.assertEqual(item.played, True)
        item.played = False
        self.assertEqual(item.played, False)
Example #11
0
 def test_select(self):
     # noinspection PyUnresolvedReferences
     with mock.patch.object(xbmcgui.ListItem, 'select') as mock_select:
         item = ListItem()
         item.selected = True
         mock_select.assert_called_with(True)
         item.select(False)
         mock_select.assert_called_with(False)
Example #12
0
 def test_select(self):
     # noinspection PyUnresolvedReferences
     with mock.patch.object(xbmcgui.ListItem, 'select') as mock_select:
         item = ListItem()
         item.selected = True
         mock_select.assert_called_with(True)
         item.select(False)
         mock_select.assert_called_with(False)
Example #13
0
 def test_stream_info(self):
     # noinspection PyUnresolvedReferences
     with mock.patch.object(xbmcgui.ListItem,
                            'addStreamInfo') as mock_stream_info:
         item = ListItem()
         item.add_stream_info('video', {'duration': 185})
         mock_stream_info.assert_called_with('video', {'duration': 185})
         item.add_stream_info('audio', {'language': 'en'})
         mock_stream_info.assert_called_with('audio', {'language': 'en'})
Example #14
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 #15
0
def dashboard_old(listlikes, alltags, litems):
    for item in listlikes:
        if item.get('type', '') == 'video':
            b = item
            img = item.get("thumbnail_url", __imgtumblr__)
            img2 = item.get("image_permalink", __imgtumblr__)
            alltags.extend(item.get('tags', []))
            try:
                if len(b.get('slug', '')) > 0:
                    lbl = b.get('slug', '')
                elif len(b.get('title', '')) > 0:
                    lbl = b.get('title', '')
                elif len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                elif len(b.get('summary', '')) > 0:
                    lbl = b.get('summary', '')
                elif len(b.get('source_title', '')) > 0:
                    lbl = b.get('source_title', '')
                else:
                    lbl = b.get('short_url', '')
                if len(item.get('summary', '')) > 0:
                    lbl2 = item.get('summary', '')
                else:
                    lbl2 = item.get('blog_name', '') + " / " + item.get('source_title', '') + "(" + item.get(
                        'slug_name', '') + ")"
            except:
                lbl = b.get('blog_name', '')
                lbl2 = b.get('short_url', '')
            vidurl = item.get('video_url', '')
            img = item.get('thumbnail_url',
                           item.get('image_permalink', item.get('image_permalink', __imgtumblr__))).replace('https:',
                                                                                                            'http:')
            img2 = item.get('image_permalink',
                            item.get('thumbnail_url', item.get('thumbnail_url', __imgtumblr__))).replace('https:',
                                                                                                         'http:')
            if vidurl is not None and len(vidurl) > 10:
                if len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                litem = ListItem(label=lbl, label2=lbl2, icon=img2, thumbnail=img, path=vidurl)
                litem.playable = True
                litem.is_folder = False
                if item.get('date', '') is not None:
                    rdate = str(item.get('date', '')).split(' ', 1)[0].strip()
                litem.set_info(info_type='video', info_labels={'Date': rdate})
                litem.set_art({'poster': img2, 'thumbnail': img, 'fanart': img2})
                pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
                pathaddlike = plugin.url_for(endpoint=addlike, id=item.get('id', ''))
                litem.add_context_menu_items(
                    [('Download', 'RunPlugin({0})'.format(pathdl)), ('Like', 'RunPlugin({0})'.format(pathaddlike)),
                     ('Show Image', 'ShowPicture({0})'.format(img)), ])
                litems.append(litem)
    item = listlikes[-1]
    plugin.set_setting('lastid', str(item.get('id', lastid)))
    savetags(alltags)
    # litems.append(nextitem)
    return litems
Example #16
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 #17
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 #18
0
    def test_art(self):
        item = ListItem()
        art = {'thumb': None, 'icon': None}
        self.assertEqual(item.art, art)

        art2 = {'thumb': 'something', 'icon': 'else'}
        item.art = art2
        self.assertEqual(item.art, art2)

        item.set_art(art)
        self.assertEqual(item.art, art)
Example #19
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 #20
0
def index():
    # setview_list()
    litems = []
    itemdashvids = {}
    itemliked = {}
    itemfollowing = {}
    itemtagbrowse = {}
    itemtagged = {}
    itemsearch = {}
    tstamp = str(time.mktime(
        (datetime.datetime.now() - weekdelta).timetuple())).split('.', 1)[0]
    info = {"name": "Not logged in", "likes": 1, "following": 1}
    tinfo = namedtuple("tumblr_info", field_names=info.keys())(*info.values())
    try:
        userinforesp = tclient.info()
        if isinstance(userinforesp, dict):
            info = userinforesp.get("user", {})
            tinfo = namedtuple('tumblr_info', info.keys(),
                               rename=True)(*info.values())
    except:
        plugin.notify("ERROR: Tumblr needs this addon to be authorized.")
    try:
        lbldash = "[B]{0}[/B]'s Dashboard".format(tinfo.name)
        lblfol = "Following: {0}".format(str(tinfo.following))
        lbllike = "Liked: {0}".format(str(tinfo.likes))
        itemdash = ListItem(label=lbldash,
                            icon=__imgtumblr__,
                            path=plugin.url_for(dashboard, offset=0))
        itemfollowing = ListItem(label=lblfol,
                                 path=plugin.url_for(blogs_following,
                                                     offset=0))
        itemliked = ListItem(label=lbllike,
                             path=plugin.url_for(liked, offset=0))
        litems.append(itemdash)
        litems.append(itemfollowing)
        litems.append(itemliked)
        #itemargs = {'offset': 0, 'lastid':0}
        #itemdashvids = makeitem(name='Dashboard Videos', img=__imgtumblr__,  path='dashboard', kwargs=itemargs)
        #itemargs = {'offset':0}
        #itemliked = makeitem(name='Liked Videos', path='liked', kwargs=itemargs)
        #itemfollowing = makeitem(name='Following', path='blogs_following', kwargs=itemargs)
        #itemargs = {'timestamp': str(tstamp)}
        #itemtagbrowse = makeitem(name='Browse Tags', path='taglist', kwargs=itemargs) #dict(timestamp=str(tstamp)))
        #itemargs.update({'tagname': 0})
        #litems.append(itemdash)
        #litems.append(itemfollowing)
        #litems.append(itemliked)
        #litems.append(itemtagbrowse)
    except Exception as ex:
        outmsg = "{0}".format(str(ex))
        plugin.notify(msg=outmsg, delay=7000)
        print outmsg
    return litems
Example #21
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 #22
0
def dashboard_items(results=[]):
    alltags = []
    litems = []
    for item in results:
        if item.get('type', '') == 'video':
            b = {}
            b.update(item)
            lbl = ""
            lbl2 = ""
            img = item.get('thumbnail_url',
                           item.get('image_permalink', __imgtumblr__))
            alltags.extend(item.get('tags', []))
            try:
                if len(b.get('slug', '')) > 0:
                    lbl = b.get('slug', '')
                elif len(b.get('title', '')) > 0:
                    lbl = b.get('title', '')
                elif len(b.get('caption', '')) > 0:
                    lbl = Strip(b.get('caption', ''))
                elif len(b.get('summary', '')) > 0:
                    lbl = b.get('summary', '')
                elif len(b.get('source_title', '')) > 0:
                    lbl = b.get('source_title', '')
                else:
                    lbl = b.get('short_url', '')
                if len(item.get('summary', '')) > 0:
                    lbl2 = item.get('summary', '')
                else:
                    lbl2 = item.get('blog_name', "") + " / " + item.get(
                        'source_title', '') + "(" + item.get('slug_name',
                                                             '') + ")"
            except:
                lbl = b.get(b.keys()[0], "")
                lbl2 = b.get(b.keys()[-1], "")
            vidurl = item.get('video_url', "")
            if vidurl is not None and len(vidurl) > 10:
                litem = ListItem(label=lbl,
                                 label2=lbl2,
                                 icon=img,
                                 thumbnail=img,
                                 path=vidurl)
                litem.playable = True
                litem.is_folder = False
                if item.get('date', '') is not None:
                    rdate = str(item.get('date', '')).split(' ', 1)[0].strip()
                litem.set_info(info_type='video', info_labels={'Date': rdate})
                litem.set_art({'poster': img, 'thumbnail': img, 'fanart': img})
                pathdl = plugin.url_for(endpoint=download, urlvideo=vidurl)
                litem.add_context_menu_items([
                    ('Download', 'RunPlugin({0})'.format(pathdl)),
                ])
                litems.append(litem)
    return litems, alltags
Example #23
0
def taglist(timestamp=0):
    # setview_list()
    if not os.path.exists(tagpath):
        json.dump([], fp=open(tagpath, mode='w'))
    litems = []
    alltags = json.load(open(tagpath))
    for tag in alltags:
        turl = plugin.url_for(tags, tagname=tag, timestamp=str(timestamp))
        li = ListItem(label=tag, label2=tag, icon=__imgtumblr__, thumbnail=__imgtumblr__, path=turl)
        li.is_folder = True
        litems.append(li)
    return litems
Example #24
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 #25
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 #26
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 #27
0
def category(name='', url=''):
    html = ''
    if not str(url).startswith('http'):
        url = __BASEURL__ + '/' + url
    html = DL(url)
    banner = 'DefaultVideoFolder.png'
    epre = re.compile(
        ur'href="(https?://watchseries-online.[a-z]+/episode/.+?)" .+?<span.+?</span>(.+?)</a>'
    )
    matches = epre.findall(html)
    litems = []
    if len(matches) > 1000: matches = matches[0:1000]
    for eplink, epname in matches:
        itempath = plugin.url_for(endpoint=episode, name=epname, url=eplink)
        item = ListItem(label=epname,
                        label2=eplink,
                        icon='DefaultVideo.png',
                        thumbnail='DefaultVideo.png',
                        path=itempath)
        litems.append(item)
        plugin.log.info(msg="** {0}\t{1}".format(epname, eplink))
    plugin.notify(msg="Category {0}".format(name), title=str(len(litems)))
    if plugin.get_setting(key='sortalpha', converter=bool):
        litems.sort(key=lambda litems: litems.label, reverse=True)
    return litems
Example #28
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 #29
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 #30
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 #31
0
    def test_context_menu(self):
        menu_items = [('label1', 'foo'), ('label2', 'bar')]
        item = ListItem()
        item.add_context_menu_items(menu_items)
        self.assertEqual(item.get_context_menu_items(), menu_items)

        extra_menu_item = ('label3', 'baz')
        menu_items.append(extra_menu_item)
        item.add_context_menu_items([extra_menu_item])
        self.assertEqual(item.get_context_menu_items(), menu_items)
Example #32
0
def resolveurl():
    playable = None
    resolved = ""
    url = plugin.keyboard(default='', heading='Video Page URL')
    if url is not None:
        name = url
        if len(url) > 0:
            url = url.encode('utf-8', 'ignore')
            item = ListItem(label=name,
                            label2=url,
                            icon='DefaultVideo.png',
                            thumbnail='DefaultVideo.png',
                            path=plugin.url_for(endpoint=play, url=url))
            item.playable = True
            item.set_info(info_type='video',
                          info_labels={
                              'Title': url,
                              'Plot': url
                          })
            item.add_stream_info(stream_type='video', stream_values={})
            playable = play(url)

            try:
                resolved = urlresolver.resolve(url)
            except:
                resolved = ""
            plugin.notify(msg=resolved, title="Playing..")
            return plugin.play_video(playable)
    #plugin.redirect(plugin.url_for(index))
    #plugin.clear_added_items()
    #plugin.end_of_directory()
    #return None
    return None
Example #33
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 #34
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 #35
0
    def test_selected(self):
        item = ListItem()
        self.assertEqual(item.selected, False)
        self.assertEqual(item.is_selected(), False)

        item.selected = True
        self.assertEqual(item.selected, True)
        self.assertEqual(item.is_selected(), True)

        item.select(False)
        self.assertEqual(item.selected, False)
        self.assertEqual(item.is_selected(), False)
Example #36
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 #37
0
def oldplay(title, video, url):
    try:
        if vidurl is None:
            m1 = re.compile('href="(https?.+mp4[^"]*)".', re.I + re.M + re.S + re.U).findall(vidhtml)
            m2 = re.compile('flv_url=(http[^"]+?)&amp;', re.I+re.M).findall(vidhtml)
            m3 = re.compile("videoUrl: '([^']+)", re.I+re.M).findall(vidhtml)
            m4 = re.compile("480: '([^']+)", re.I+re.M).findall(vidhtml)
            m5 = re.compile('source src="([^"]+)"', re.I+re.M).findall(vidhtml)
            m6 = re.compile("var player_quality_480p = '([^\"]+.mp4[^']*)';", re.I+re.M).findall(vidhtml)
            if m1 is not None:
                vidurl = m1.pop()
                xbmc.log("MATCH 1 = {0}".format(vidurl))
            if m2 is not None:
                vidurl = m2.pop()
                xbmc.log("MATCH 2 = {0}".format(vidurl))
            if m3 is not None:
                vidurl = m3.pop()
                xbmc.log("MATCH 3 = {0}".format(vidurl))                    
            if m4 is not None:
                vidurl = m4.pop()
                xbmc.log("MATCH 4 = {0}".format(vidurl))                    
            if m5 is not None:
                vidurl = m5.pop()
                xbmc.log("MATCH 5 = {0}".format(vidurl))
            if m6 is not None:
                vidurl = m6.pop()
                xbmc.log("MATCH 6 = {0}".format(vidurl))
            #matches = re.compile("videoUrl: '([^']*)',", re.I + re.M + re.S + re.U).findall(vidhtml)[0]
            #vidurl = matches
            #vidurl = matches.split(' ', 1)[0].strip('"')
            #xbmc.Player().play(vidurl)
            if vidurl is not None:
                xbmc.log("PLAY matches vidpage: \n{0}".format(vidurl))
                vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
                vli.playable = True
                plugin.set_resolved_url(vli)
                plugin.play_video(vli)
                # return plugin.play_video(vli)
            else:
                xbmc.log("FAILED to resolve url to movie file. {0}".format(url))
    except:
        xbmc.log("failed to resolve url to movie file.")
Example #38
0
def play(title, video, url):
    resolved = None
    mediaurl = None
    vidhtml = urllib2.urlopen(url).read()
    vidurl = ''
    try:        
        matches = re.compile('(http://[^"<]+?.mp4[^"<]+?)"', re.I + re.M + re.S + re.U).findall(vidhtml)[0]
        if matches is not None:
            vidurl = matches
            xbmc.log("MATCH MP4 = {0}".format(vidurl))            
            vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
            vli.playable = True
            #plugin.set_resolved_url(plugin.url_for(play, title=title, video=video, url=url))
            #xbmc.Player().play(vidurl)
            #plugin.play_video(vli)
            #return plugin.play_video(vli)                        
            #return xbmc.Player().play(vidurl)
    except:
        pass
    try:
        if vidurl == '':
            matches2 = re.compile('(http://[^"<]+?.flv[^"<]+?)"', re.I + re.M + re.S + re.U).findall(vidhtml)[0]            
            if matches2 is not None:
                vidurl = matches2
                xbmc.log("MATCH MP4 = {0}".format(vidurl))            
                vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
                vli.playable = True
                #plugin.set_resolved_url(plugin.url_for(play, title=title, video=video, url=url))
                #xbmc.Player().play(vidurl)
                #plugin.set_resolved_url(vli)
                #plugin.play_video(vli)
                #plugin.set_resolved_url(plugin.url_for(play, title=title, video=video, url=url))
            #return plugin.play_video(vli)
    except:
        pass
    #plugin.set_resolved_url(plugin.url_for(play, title=title, video=video, url=url))
    try:
        if vli is not None:
            plugin.set_resolved_url(vli)
            return plugin.play_video(vli)
    except:
        pass
Example #39
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 #40
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 #41
0
    def test_context_menu(self):
        menu_items = [('label1', 'foo'), ('label2', 'bar')]
        item = ListItem()
        item.add_context_menu_items(menu_items)
        self.assertEqual(item.get_context_menu_items(), menu_items)

        extra_menu_item = ('label3', 'baz')
        menu_items.append(extra_menu_item)
        item.add_context_menu_items([extra_menu_item])
        self.assertEqual(item.get_context_menu_items(), menu_items)
Example #42
0
 def test_label2(self):
     item = ListItem('foo')
     self.assertIsNone(item.label2)
     item.label2 = 'bar'
     self.assertEqual(item.label2, 'bar')
     item.set_label2('baz')
     self.assertEqual(item.get_label2(), 'baz')
Example #43
0
 def test_label(self):
     item = ListItem('foo')
     self.assertEqual(item.label, 'foo')
     item.label = 'bar'
     self.assertEqual(item.label, 'bar')
     item.set_label('baz')
     self.assertEqual(item.get_label(), 'baz')
Example #44
0
    def test_selected(self):
        item = ListItem()
        self.assertEqual(item.selected, False)
        self.assertEqual(item.is_selected(), False)

        item.selected = True
        self.assertEqual(item.selected, True)
        self.assertEqual(item.is_selected(), True)

        item.select(False)
        self.assertEqual(item.selected, False)
        self.assertEqual(item.is_selected(), False)
Example #45
0
def play(title, video, url):
    """
    Play attempts to scrape the video's page and find the actual video file to play. This is still buggy but seems to work on
    a lot of the sites but not all the time so any help on this function working better would be appreciated. I pass in the
    title of the movie and the video tags the Thumbnail which I use to create a proper ListItem with the scrapped MP4 url
    :param title: Video Title to play passed to XBMC in a new ListItem object with resolved URL of video scraped from url
    :param video: Thumbnail URL of the video used as the icon and thumbnail for ListItem to play
    :param url: URL of the embed/video page to scrape for the real playable video file
    :return: ListItem of video with path = scraped url of the MP4/Video file hopefully
    """
    resolved = None
    mediaurl = None
    vidhtml = urllib2.urlopen(url).read()
    vidurl = ''
    vli = None
    try:
        matches = re.compile('(http://[^"<]+?.mp4[^"<]+?)"', re.I + re.M + re.S + re.U).findall(vidhtml)[0]
        if matches is not None:
            vidurl = matches
            xbmc.log("MATCH MP4 = {0}".format(vidurl))
            vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
            vli.playable = True
        else:
            matches = re.compile('(http://[^"<]+?.flv[^"<]+?)"', re.I + re.M + re.S + re.U).findall(vidhtml)[0]
            if matches is not None:
                vidurl = matches
                xbmc.log("MATCH FLV = {0}".format(vidurl))
                vli = ListItem(label=title, label2=url, icon=video, thumbnail=video, path=vidurl)
                vli.playable = True
    except:
        pass
    try:
        if vli is not None:
            plugin.set_resolved_url(vli)
            plugin.play_video(vli)
            # return plugin.play_video(vli)
    except:
        pass
Example #46
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 #47
0
    def test_path(self):
        item = ListItem()
        self.assertIsNone(item.path)

        item.path = 'bar'
        self.assertEqual(item.path, 'bar')
        self.assertEqual(item.get_path(), 'bar')

        item.set_path('baz')
        self.assertEqual(item.path, 'baz')
        self.assertEqual(item.get_path(), 'baz')
Example #48
0
    def test_thumbnail(self):
        item = ListItem()
        self.assertIsNone(item.thumbnail)

        item.thumbnail = 'bar'
        self.assertEqual(item.thumbnail, 'bar')
        self.assertEqual(item.get_thumbnail(), 'bar')

        item.set_thumbnail('baz')
        self.assertEqual(item.thumbnail, 'baz')
        self.assertEqual(item.get_thumbnail(), 'baz')
Example #49
0
    def test_icon(self):
        item = ListItem()
        self.assertIsNone(item.icon)

        item.icon = 'bar'
        self.assertEqual(item.icon, 'bar')
        self.assertEqual(item.get_icon(), 'bar')

        item.set_icon('baz')
        self.assertEqual(item.icon, 'baz')
        self.assertEqual(item.get_icon(), 'baz')
Example #50
0
def resolveurl():
    url = plugin.keyboard(default='', heading='Video Page URL')
    if url is not None:
        name = url
        if len(url) > 0:
            item = ListItem(label=name, label2=url, icon='DefaultVideo.png', thumbnail='DefaultVideo.png', path=plugin.url_for(endpoint=play, url=url))
            item.set_is_playable(True)
            item.set_info(info_type='video', info_labels={'Title': url, 'Plot': url})
            item.add_stream_info(stream_type='video', stream_values={})
            playable = play(url)
            plugin.notify(msg=playable.path, title="Playing..")
            plugin.play_video(playable)
    #plugin.redirect(plugin.url_for(index))
    plugin.clear_added_items()
    plugin.end_of_directory()
Example #51
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 #52
0
def resolveurl():
    if plugin.get_setting('debugon', converter=bool): web_pdb.set_trace()

    url = plugin.keyboard(default='', heading='Video Page URL')
    if url is not None:
        name = url
        if len(url) > 0:
            item = ListItem(label=name, label2=url, icon='DefaultVideo.png', thumbnail='DefaultVideo.png',
                            path=plugin.url_for(endpoint=play, url=url))
            item.playable = True
            item.set_info(type='video', info_labels={'Title': url, 'Plot': url})
            item.add_stream_info(stream_type='video', stream_values={})
            playable = play(url)
            plugin.notify(msg=playable.path, title="Playing..")
            plugin.play_video(playable)
    plugin.clear_added_items()
    plugin.end_of_directory()
Example #53
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 #54
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 #55
0
 def test_set_property(self, mock_set_property):
     item = ListItem()
     item.set_property('foo', 'bar')
     mock_set_property.assert_called_with('foo', 'bar')
Example #56
0
 def test_get_property(self, mock_get_property):
     mock_get_property.return_value = 'bar'
     item = ListItem()
     self.assertEqual(item.get_property('foo'), 'bar')
     mock_get_property.assert_called_with('foo')
Example #57
0
def new_viditem(v={}, as_dict=False):
    pathdl = plugin.url_for(endpoint=download, vurl=v.get('contentUrl', v.get('hostPageUrl', '')))
    ctxlist = []
    citem = ('Download', 'RunPlugin({0})'.format(pathdl),)
    ctxlist.append(citem)
    pathdel = plugin.url_for(endpoint=fav_del, idvid=v.get('videoId', ''))
    citem = ('DELETE', 'RunPlugin({0})'.format(pathdel),)
    ctxlist.append(citem)
    img = v.get('thumbnail', v.get('thumbnailUrl', 'DefaultVideo.png'))
    lbl = v.get('label', v.get('name', ''))
    lbl2 = v.get('label2', v.get('videoId', ''))
    vidpath = v.get('path', None)
    if vidpath is None:
        vidpath = plugin.url_for(endpoint=play, vtitle=v.get('name', lbl), vurl=v.get('contentUrl', v.get('hostPageUrl', lbl2)))
    xitem = None
    if not as_dict:
        xitem = ListItem(label=lbl, label2=lbl2, icon=img, thumbnail=img, path=vidpath)
        xitem.add_context_menu_items(items=ctxlist, replace_items=False)
        xitem.playable = True
        xitem.is_folder = False
        xitem.set_info(info_type='video', info_labels={'Title': lbl, 'Plot': lbl2, 'Premiered': v.get('datePublished', '')})
        xitem.thumbnail = img
        xitem.icon = img
        idvid = v.get('videoId', 0)
        if idvid is not 0:
            xitem.set_property(key='videoId', value=idvid)
            xitem.set_info(info_type='video', info_labels={'VideoID': idvid})
    else:
        xitem = {'label': lbl, 'label2': lbl2, 'icon': img, 'thumbnail': img, 'is_playable': True, 'path': vidpath}
    return xitem
Example #58
0
 def test_as_tuple(self):
     item = ListItem()
     self.assertEqual(item.as_tuple(), (None, item._listitem, True))