当前位置: 首页>>代码示例>>Python>>正文


Python xbmcswift2.ListItem类代码示例

本文整理汇总了Python中xbmcswift2.ListItem的典型用法代码示例。如果您正苦于以下问题:Python ListItem类的具体用法?Python ListItem怎么用?Python ListItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ListItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_select

 def test_select(self):
     with 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)
开发者ID:beenje,项目名称:xbmcswift2,代码行数:7,代码来源:test_listitem.py

示例2: test_label

 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')
开发者ID:beenje,项目名称:xbmcswift2,代码行数:7,代码来源:test_listitem.py

示例3: test_stream_info

 def test_stream_info(self):
     with 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', {'languange': 'en'})
         mock_stream_info.assert_called_with('audio', {'languange': 'en'})
开发者ID:Opvolger,项目名称:xbmcswift2,代码行数:7,代码来源:test_listitem.py

示例4: test_label2

 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')
开发者ID:beenje,项目名称:xbmcswift2,代码行数:7,代码来源:test_listitem.py

示例5: video_detail

def video_detail(seasonId):
    detail = Meiju.video_detail(seasonId)
    season_data = detail["data"]["season"]
    title = season_data["title"]
    SEASON_CACHE[seasonId] = detail["data"]  # store season detail
    history = HISTORY.get("list", None)
    playing_episode = "0"
    if history is not None:
        for l in history:
            if l["seasonId"] == seasonId:
                playing_episode = l["index"]
    for episode in season_data["playUrlList"]:
        label = title + str(episode["episode"])
        if episode["episode"] == playing_episode:
            label = "[B]" + colorize(label, "green") + "[/B]"
        item = ListItem(**{
            'label': label,
            'path': plugin.url_for("play_season", seasonId=seasonId, index=episode["episode"], Esid=episode["episodeSid"]),
        })
        item.set_info("video", {"plot": season_data["brief"],
                                "TVShowTitle": title,
                                "episode": int(episode["episode"]),
                                "season": 0})
        item._listitem.setArt({"poster": season_data["cover"]})
        item.set_is_playable(True)
        yield item
    plugin.set_content('episodes')
开发者ID:brmnh,项目名称:xbmc-addons-chinese,代码行数:27,代码来源:path.py

示例6: play

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
开发者ID:moedje,项目名称:kodi-repo-gaymods,代码行数:55,代码来源:old_addon.py

示例7: tvitem

def tvitem(adapter, channel):
    titleandtime = channel.nowstarttimeandtitle()

    item = ListItem(label=channel.name,
                    label2=titleandtime,
                    icon=channel.getimagefile(config.tvconfig.channelsdir),
                    thumbnail=channel.getimagefile(config.tvconfig.channelsdir),
                    path=plugin.url_for(str('play_channel'), adapter=adapter, channelid=str(channel.channelid)))

    item.set_is_playable(True)
    item.set_info('video',
                  {
                      'title': channel.name[:15],
                      'tvshowtitle': titleandtime,
                      'duration': channel.v_nowduration,
                      'plot': channel.v_nowdescription,
                      'plotoutline': channel.v_nowdescription,
                      'tagline': channel.nowstarttimeandtitle(),
                      'playcount': 0,
                      #'cast': channel.v_nowactors,
                      'fanart': channel.v_nowfanart,
                      'extrafanart': channel.v_nowposter,
                      'originaltitle': channel.v_nowtitle,
                      'year': channel.v_nowyear,
                      'album': titleandtime,  # I used album 'cause I haven't found another field to display label2
                      'genre': channel.v_nowgenre
                  })
    item.add_context_menu_items(create_context_menu(channel.name, adapter, channel.channelid), replace_items=True)
    item.add_stream_info('video',
                         {'duration': try_parse_int(channel.v_nowduration) * 60, 'plot': channel.v_nowdescription})
    return item
开发者ID:giogris,项目名称:tvs,代码行数:31,代码来源:addon.py

示例8: test_from_dict_props

    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')
开发者ID:Opvolger,项目名称:xbmcswift2,代码行数:12,代码来源:test_listitem.py

示例9: play

def play(artist, track):
    data = getTrack(artist, track)
    print data
    item = ListItem()
    item.set_label('%s - %s' % (artist, track))
    item.set_path(data['url'])
    item.set_played(True)
    xbmcplugin.setResolvedUrl(plugin.handle, True, item.as_xbmc_listitem())
开发者ID:Backmute,项目名称:seppius-xbmc-repo,代码行数:8,代码来源:addon.py

示例10: play

    def play(self, videoId):
        api = NetworkTenVideo()
        media = api.get_media_for_video(videoId)
        self.log.debug("Found media renditions for video: %s", repr(media.items))
        if len(media.items):
            # Blindly go for the highest bitrate for now.
            # Later versions could include a customisable setting of which stream to use
            media_sorted = sorted(media.items, key=lambda m: m.encodingRate, reverse=True)
            media = media_sorted[0]
            path = media.defaultURL
            self.log.info("Using rendition: %s with url: %s" % (media, path))
        else:
            # Fallback to API FLVFullLength (e.g. for live streams)
            media = api.get_fallback_media_for_video(videoId)
            path = media.remoteUrl
            self.log.info("Using fallback rendition: %s with url: %s" % (media, path))

        if path.startswith("rtmp"):
            path = path.replace("&mp4:", " playpath=mp4:")
            path += " swfVfy=true swfUrl=%s pageUrl=%s" % (SWF_URL, PAGE_URL)

        # Set the resolved url, and include media stream info
        item = ListItem.from_dict(path=path)
        item.add_stream_info(
            "video", {"codec": media.videoCodec, "width": media.frameWidth, "height": media.frameHeight}
        )
        self.plugin.set_resolved_url(path)
开发者ID:johnmee,项目名称:plugin.video.catchuptv.au.ten,代码行数:27,代码来源:play.py

示例11: play

  def play(self, videoId):
    api = NetworkTenVideo()
    media = api.get_media_for_video(videoId)
    self.log.debug('Found media renditions for video: %s', repr(media))
    if len(media):
        # Blindly go for the highest bitrate for now.
        # Later versions could include a customisable setting of which stream to use
        media_sorted = sorted(media, key=lambda m: m.encodingRate, reverse=True)
        media = media_sorted[0]
        path = media.url
        self.log.info('Using rendition: %s with url: %s' % (media, path))
    else:
        # Fallback to API FLVFullLength (e.g. for live streams)
        media = api.get_fallback_media_for_video(videoId)
        if media.remoteUrl:
          path = media.remoteUrl
          self.log.info('Using fallback rendition: %s with url: %s' % (media, path))
        else:
          # attempt to deal with DRM'd content by falling back to mobile HLS stream
          path = "http://c.brightcove.com/services/mobile/streaming/index/master.m3u8?videoId=%s" % videoId
          self.log.info('Using fallback rendition unavailable - falling back to mobile HLS stream: %s' % path)

    if path.startswith('rtmp'):
      path = path.replace('&mp4:', ' playpath=mp4:')
      path += ' swfVfy=true swfUrl=%s pageUrl=%s' % (SWF_URL, PAGE_URL)

    # Set the resolved url, and include media stream info
    item = ListItem.from_dict(path=path)
    item.add_stream_info('video', {'codec': media.videoCodec, 'width': media.frameWidth, 'height': media.frameHeight})
    self.plugin.set_resolved_url(path)
开发者ID:xbmc-catchuptv-au,项目名称:plugin.video.catchuptv.au.ten,代码行数:30,代码来源:play.py

示例12: interactive

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

        # If we have parent items, include the top of the stack in the list
        # item display
        parent_item = None
        if parent_stack:
            parent_item = parent_stack[-1]
        items = [item for item in once(plugin, parent_item=parent_item)
                 if not item.get_played()]
        selected_item = get_user_choice(items)
开发者ID:beenje,项目名称:xbmcswift2,代码行数:26,代码来源:app.py

示例13: test_from_dict

 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')],
         'context_menu': [('label', 'action')],
         'is_playable': True}
     with patch.object(ListItem, 'set_info', spec=True) as mock_set_info:
         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'})
     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.is_folder, False)
开发者ID:beenje,项目名称:xbmcswift2,代码行数:26,代码来源:test_listitem.py

示例14: get_album

def get_album(albumId):
    c_list = Meiju.get_album(albumId)
    for one in c_list["data"]["results"]:
        item = ListItem(**{
            'label': one.get("title"),
            'path': plugin.url_for("detail", seasonId=one.get("id")),
            'icon': one["cover"],
            'thumbnail': one["cover"],
        })
        item.set_info("video", {"plot": one.get("brief", ""),
                                "rating ": float(one["score"]),
                                "genre": one["cat"],
                                "season": one["seasonNo"]})
        item.set_is_playable(False)
        yield item
    plugin.set_content('TVShows')
开发者ID:2php,项目名称:xbmc-addons-chinese,代码行数:16,代码来源:path.py

示例15: episode

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(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
开发者ID:moedje,项目名称:kodi-repo-gaymods,代码行数:30,代码来源:oldaddon.py


注:本文中的xbmcswift2.ListItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。