Exemplo n.º 1
0
def get_item(pid): 
    #print "Getting %s" % (pid)
    p = iplayer.programme(pid)
    #print "%s is %s" % (pid, p.title)
      
    #for i in p.items:
    #    if i.kind in ['programme', 'radioProgrammme']:
    #        return i
    return p.programme
Exemplo n.º 2
0
def get_item(pid):
    #print "Getting %s" % (pid)
    p = iplayer.programme(pid)
    #print "%s is %s" % (pid, p.title)

    #for i in p.items:
    #    if i.kind in ['programme', 'radioProgrammme']:
    #        return i
    return p.programme
def watch(feed, pid):

    subtitles_file = None
    item      = iplayer.programme(pid).programme
    thumbnail = item.programme.thumbnail
    title     = item.programme.title
    summary   = item.programme.summary
    date      = item.programme.date
    channel   = None
    thumbfile = None
    if feed and feed.name:
        channel = feed.name
    utils.log('watching channel=%s pid=%s' % (channel, pid),xbmc.LOGINFO)
    utils.log('thumb =%s   summary=%s' % (thumbnail, summary),xbmc.LOGINFO)
    subtitles = get_setting_subtitles()

    if thumbnail:
        if feed is not None and pid == feed.channel:
            # Listening to a live radio station, use the pre-downloaded file
            thumbfile = get_feed_thumbnail(feed)
        else:
            # attempt to use the existing thumbnail file
            thumbcache = xbmc.getCacheThumbName( sys.argv[ 0 ] + sys.argv[ 2 ] )
            if utils.get_os() == "xbox":
                thumbfile = os.path.join( xbmc.translatePath( "special://profile" ), "Thumbnails", "Video", thumbcache[ 0 ], thumbcache )
            else:
                thumbfile = os.path.join( xbmc.translatePath( "special://profile" ), "Thumbnails", thumbcache[ 0 ], thumbcache )
            utils.log('Reusing existing thumbfile=%s for url %s%s' % (thumbfile, sys.argv[ 0 ], sys.argv[ 2 ]),xbmc.LOGINFO)

    if thumbnail and not os.path.isfile(thumbfile):
        # thumbnail wasn't available locally so download
        try:
            # The thumbnail needs to accessed via the local filesystem
            # for "Media Info" to display it when playing a video
            iplayer.httpretrieve(thumbnail, thumbfile)
        except:
            pass

    if item.is_tv and item.is_live:
        (media_list, above_limit) = item.get_available_streams_live()
    else:
        (media_list, above_limit) = item.get_available_streams()

    if len(media_list) == 0:
        # Nothing usable was found
        d = xbmcgui.Dialog()
        d.ok('Stream Error', 'Can\'t locate any usable streams.')
        return False

    for media in media_list:
        player = None
        listitem = xbmcgui.ListItem(label=title)
        if item.is_tv:
            # TV Stream
            iconimage = 'DefaultVideo.png'

            if above_limit:
                d = xbmcgui.Dialog()
                if d.yesno('Default Stream Not Available', 'Play higher bitrate stream?') == False:
                    return False

            url = media.url
            utils.log('watching url=%s' % url,xbmc.LOGINFO)

            if subtitles:
                subtitles_media = item.get_media_list_for('captions', None)
                if subtitles_media and len(subtitles_media) > 0:
                    subtitles_file = download_subtitles(subtitles_media[0].url)

            if not item.live:
                listitem.setInfo('video', {
                                           "TVShowTitle": title,
                                           'Plot': summary + ' ' + date,
                                           'PlotOutline': summary,})
            play=xbmc.PlayList(xbmc.PLAYLIST_VIDEO)

        else:

            if not media:
                d = xbmcgui.Dialog()
                d.ok('Stream Error', 'Error: can\'t locate radio stream')
                return False

            if media.application in ['wma9', 'wma+asx']:
                url = parse_asx(media.url)
            else:
                url = media.url

            utils.log('Listening to url=%s' % url,xbmc.LOGINFO)
            listitem.setInfo(type='Music', infoLabels = {'title': title})
            listitem.setIconImage('defaultAudio.png')

        utils.log('Playing preference %s %s' % (media.connection_kind, media.application),xbmc.LOGINFO)

        if thumbfile:
            listitem.setIconImage(thumbfile)
            listitem.setThumbnailImage(thumbfile)

        listitem.setPath(url)
        xbmcplugin.setResolvedUrl(__plugin_handle__, succeeded = True, listitem = listitem)

        xbmc.sleep(500)
        # Successfully started playing something?
        if xbmc.Player().isPlaying():
            break;

    # Auto play subtitles if they have downloaded
    utils.log("subtitles: %s   - subtitles_file %s " % (subtitles,subtitles_file),xbmc.LOGINFO)
    if subtitles == 'autoplay' and subtitles_file:
        xbmc.Player().setSubtitles(subtitles_file)

    if not item.is_tv:
        # Switch to a nice visualisation if playing a radio stream
        xbmc.executebuiltin('ActivateWindow(Visualisation)')

    del item
Exemplo n.º 4
0
def watch(feed, pid):

    subtitles_file = None
    item = iplayer.programme(pid).programme
    thumbnail = item.programme.thumbnail
    title = item.programme.title
    summary = item.programme.summary
    date = item.programme.date
    channel = None
    thumbfile = None
    if feed and feed.name:
        channel = feed.name
    utils.log('watching channel=%s pid=%s' % (channel, pid), xbmc.LOGINFO)
    utils.log('thumb =%s   summary=%s' % (thumbnail, summary), xbmc.LOGINFO)
    subtitles = get_setting_subtitles()

    if thumbnail:
        if feed is not None and pid == feed.channel:
            # Listening to a live radio station, use the pre-downloaded file
            thumbfile = get_feed_thumbnail(feed)
        else:
            # attempt to use the existing thumbnail file
            thumbcache = xbmc.getCacheThumbName(sys.argv[0] + sys.argv[2])
            if utils.get_os() == "xbox":
                thumbfile = os.path.join(
                    xbmc.translatePath("special://profile"), "Thumbnails",
                    "Video", thumbcache[0], thumbcache)
            else:
                thumbfile = os.path.join(
                    xbmc.translatePath("special://profile"), "Thumbnails",
                    thumbcache[0], thumbcache)
            utils.log(
                'Reusing existing thumbfile=%s for url %s%s' %
                (thumbfile, sys.argv[0], sys.argv[2]), xbmc.LOGINFO)

    if thumbnail and not os.path.isfile(thumbfile):
        # thumbnail wasn't available locally so download
        try:
            # The thumbnail needs to accessed via the local filesystem
            # for "Media Info" to display it when playing a video
            iplayer.httpretrieve(thumbnail, thumbfile)
        except:
            pass

    if item.is_tv and item.is_live:
        (media_list, above_limit) = item.get_available_streams_live()
    else:
        (media_list, above_limit) = item.get_available_streams()

    if len(media_list) == 0:
        # Nothing usable was found
        d = xbmcgui.Dialog()
        d.ok('Stream Error', 'Can\'t locate any usable streams.')
        return False

    for media in media_list:
        player = None
        listitem = xbmcgui.ListItem(label=title)
        if item.is_tv:
            # TV Stream
            iconimage = 'DefaultVideo.png'

            if above_limit:
                d = xbmcgui.Dialog()
                if d.yesno('Default Stream Not Available',
                           'Play higher bitrate stream?') == False:
                    return False

            url = media.url
            utils.log('watching url=%s' % url, xbmc.LOGINFO)

            if subtitles:
                subtitles_media = item.get_media_list_for('captions', None)
                if subtitles_media and len(subtitles_media) > 0:
                    subtitles_file = download_subtitles(subtitles_media[0].url)

            if not item.live:
                listitem.setInfo(
                    'video', {
                        "TVShowTitle": title,
                        'Plot': summary + ' ' + date,
                        'PlotOutline': summary,
                    })
            play = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)

        else:

            if not media:
                d = xbmcgui.Dialog()
                d.ok('Stream Error', 'Error: can\'t locate radio stream')
                return False

            if media.application in ['wma9', 'wma+asx']:
                url = parse_asx(media.url)
            else:
                url = media.url

            utils.log('Listening to url=%s' % url, xbmc.LOGINFO)
            listitem.setInfo(type='Music', infoLabels={'title': title})
            listitem.setIconImage('defaultAudio.png')

        utils.log(
            'Playing preference %s %s' %
            (media.connection_kind, media.application), xbmc.LOGINFO)

        if thumbfile:
            listitem.setIconImage(thumbfile)
            listitem.setThumbnailImage(thumbfile)

        listitem.setPath(url)
        xbmcplugin.setResolvedUrl(__plugin_handle__,
                                  succeeded=True,
                                  listitem=listitem)

        xbmc.sleep(500)
        # Successfully started playing something?
        if xbmc.Player().isPlaying():
            break

    # Auto play subtitles if they have downloaded
    utils.log(
        "subtitles: %s   - subtitles_file %s " % (subtitles, subtitles_file),
        xbmc.LOGINFO)
    if subtitles == 'autoplay' and subtitles_file:
        xbmc.Player().setSubtitles(subtitles_file)

    if not item.is_tv:
        # Switch to a nice visualisation if playing a radio stream
        xbmc.executebuiltin('ActivateWindow(Visualisation)')

    del item