本文整理汇总了Python中api.API.get_channels方法的典型用法代码示例。如果您正苦于以下问题:Python API.get_channels方法的具体用法?Python API.get_channels怎么用?Python API.get_channels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.API
的用法示例。
在下文中一共展示了API.get_channels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: play_channel
# 需要导入模块: from api import API [as 别名]
# 或者: from api.API import get_channels [as 别名]
def play_channel(category_id, channel_id):
"""
Plays selected song
:param category_id: Selected category ID
:param channel_id: Selected channel ID
:return:
"""
api = API()
user = User()
is_authenticated = user.authenticate()
recent_tracks_url = ''
channel = [item for item in api.get_channels(int(category_id))
if item['id'] == int(channel_id)][0]
url = api.get_streaming_url(channel['streams'],
user.username,
user.token,
user.is_authenticated())
if is_authenticated:
recent_tracks_url = channel['recent_tracks']['vip']
elif 'free' in channel['recent_tracks']:
recent_tracks_url = channel['recent_tracks']['free']
# is there a valid URL for channel?
if url:
url = quote(url, safe=':/[email protected]')
li = ListItem(channel['title'], channel['description'], channel['image'])
li.setArt({'thumb': '{0}/{1}'.format(config['urls']['calm_arts_host'], channel['image']),
'fanart': '{0}{1}'.format(config['urls']['calm_blurred_arts_host'], channel['image'])})
li.setInfo('music', {'Title': channel['title'].replace('CALM RADIO -', '').title(),
'Artist': channel['description']})
li.setProperty('mimetype', 'audio/mpeg')
li.setProperty('IsPlayable', 'true')
li.setInfo('music', {
'Title': channel['title'].replace('CALM RADIO -', '').title()
})
Player().play(item=url, listitem=li)
log('Playing url: {0}'.format(url))
update_artwork(channel, recent_tracks_url)
else:
# members only access
dialog = Dialog()
ret = dialog.yesno(ADDON.getLocalizedString(32200), ADDON.getLocalizedString(32201))
if ret == 1:
ADDON.openSettings()
示例2: show_channels
# 需要导入模块: from api import API [as 别名]
# 或者: from api.API import get_channels [as 别名]
def show_channels(section_id, category_id):
"""
Channels page (playable)
:param section_id: Selected section ID
:param category_id: Selected category ID
:return:
"""
api = API()
for item in api.get_channels(int(category_id)):
# list item:
li = ListItem(u'{0} {1}'.format(item['title'].replace('CALM RADIO -', '').title(),
ADDON.getLocalizedString(322023) if 'free' not in item['streams'] else '',
item['description']),
iconImage='{0}/{1}'.format(config['urls']['calm_arts_host'], item['image']),
thumbnailImage='{0}/{1}'.format(config['urls']['calm_arts_host'], item['image']))
li.setArt({
'fanart': '{0}{1}'.format(config['urls']['calm_blurred_arts_host'], item['image'])
})
li.addContextMenuItems(
[(ADDON.getLocalizedString(32300), 'RunPlugin(plugin://{0}/favorites/add/{1})'
.format(ADDON_ID, item['id']))]
)
li.setInfo('music', {
'Title': item['title'].replace('CALM RADIO -', '').title()
})
# directory item:
addDirectoryItem(
PLUGIN.handle,
PLUGIN.url_for(play_channel,
category_id=category_id,
channel_id=item['id']),
li
)
# set the content of the directory
setContent(ADDON_HANDLE, 'songs')
# end of directory:
endOfDirectory(PLUGIN.handle)
executebuiltin('Container.SetViewMode({0})'.format(
config['viewmodes']['thumbnail'][getSkinDir()
if getSkinDir() in config['viewmodes']['thumbnail'] else 'skin.confluence']
))