Esempio n. 1
0
def folge(url):
    if debuging == "true":
        xbmc.log("Folge URL" + url)
    inhalt = geturl(url)
    inhalt = inhalt.replace("'", '"')
    kurz_inhalt = inhalt[inhalt.find('<div class="clearFix">') + 1:]
    kurz_inhalt = kurz_inhalt[:kurz_inhalt.find(
        '<span class="playBtn ir">Video starten</span>')]
    match = re.compile('dataURL:"([^"]+)"', re.DOTALL).findall(kurz_inhalt)
    xmlfile = baseurl + match[0]
    xbmc.log("BR xmlfile: " + xmlfile)
    inhalt = geturl(xmlfile)
    inhalt = ersetze(inhalt)
    sub = re.compile('dataTimedText url="([^"]+)', re.DOTALL).findall(inhalt)
    if sub:
        subtitle = baseurl + sub[0]
        download_subtitles(subtitle, temp)
    inhalt = inhalt[:inhalt.find('<asset type="HDS')]
    spl = inhalt.split('<asset ')
    debug("split")
    if "Live HLS" in inhalt:
        debug("LIVE")
        was = spl[3]
        debug("Live: " + was)
    else:
        if bitrate == "Select":
            quls = re.compile(
                '<recommendedBandwidth>([^<]+)</recommendedBandwidth>',
                re.DOTALL).findall(inhalt)
            dialog = xbmcgui.Dialog()
            nr = dialog.select("Bitrate", quls)
            br = quls[nr]
            for i in range(1, len(spl), 1):
                entry = spl[i]
                if debuging == "true":
                    xbmc.log("Folge entry" + entry)
                if br in entry:
                    was = entry
        else:
            if bitrate == "Max":
                was = spl[-1]
            if bitrate == "Min":
                was = spl[1]
    debug("XXX was" + was)
    match = re.compile('<downloadUrl\>([^<]+)</downloadUrl>',
                       re.DOTALL).findall(was)
    if match:
        video = match[0]
    else:
        match = re.compile('<url>([^<]+)</url', re.DOTALL).findall(was)
        video = match[0]
    debug("XXX video url:" + video)
    debug("XXX Subtitle:" + temp + "br3.srt")
    listitem = xbmcgui.ListItem(path=video)
    if sub:
        listitem.setSubtitles([temp + "br3.srt"])
    xbmcplugin.setResolvedUrl(addon_handle, True, listitem)
Esempio n. 2
0
def folge(url):
    if debuging=="true":
      xbmc.log("Folge URL"+ url)
    inhalt = geturl(url)
    inhalt=inhalt.replace("'",'"')         
    kurz_inhalt = inhalt[inhalt.find('<div class="clearFix">')+1:]
    kurz_inhalt = kurz_inhalt[:kurz_inhalt.find('<span class="playBtn ir">Video starten</span>')]   
    match=re.compile('dataURL:"([^"]+)"', re.DOTALL).findall(kurz_inhalt)
    xmlfile=baseurl+match[0]
    xbmc.log("BR xmlfile: "+ xmlfile )
    inhalt = geturl(xmlfile) 
    inhalt=ersetze(inhalt)
    sub=re.compile('dataTimedText url="([^"]+)', re.DOTALL).findall(inhalt)
    if sub:
      subtitle= baseurl + sub[0] 
      download_subtitles(subtitle, temp)    
    inhalt = inhalt[:inhalt.find('<asset type="HDS')]  
    spl=inhalt.split('<asset ')
    debug("split")
    if "Live HLS" in inhalt:
       debug("LIVE")
       was=spl[3]
       debug ("Live: "+ was)
    else:
       if bitrate=="Select":
          quls=re.compile('<recommendedBandwidth>([^<]+)</recommendedBandwidth>', re.DOTALL).findall(inhalt)
          dialog = xbmcgui.Dialog()
          nr=dialog.select("Bitrate", quls)      
          br=quls[nr]  
          for i in range(1,len(spl),1):
            entry=spl[i]    
            if debuging=="true":
             xbmc.log("Folge entry"+ entry)
            if br in entry :
              was=entry     
       else:
        if  bitrate=="Max":
          was=spl[-1] 
        if  bitrate=="Min":
          was=spl[1]        
    debug("XXX was"+ was)          
    match=re.compile('<downloadUrl\>([^<]+)</downloadUrl>', re.DOTALL).findall(was)
    if match :
      video=match[0]
    else :
       match=re.compile('<url>([^<]+)</url', re.DOTALL).findall(was)
       video=match[0]
    debug("XXX video url:"+ video)
    debug("XXX Subtitle:"+ temp+ "br3.srt")       
    listitem = xbmcgui.ListItem(path=video)
    if sub :
      listitem.setSubtitles([ temp+ "br3.srt"])
    xbmcplugin.setResolvedUrl(addon_handle,True, listitem)  
    if url:
        url = urllib.unquote(url)
    else:
        videos_method = getattr(provider, params[FEED_PARAM])
        videos = videos_method()
        tsid = urllib.unquote(params[ID_PARAM])
        # find video with matching tsid
        for video in videos:
            if video.tsid == tsid:
                url = video.video_url(quality)
                # try to download and and convert subtitles to local SRT file
                # as of October 2014, only subtiles for complete "tagesschau" broadcasts are available
                # subtitles_url = 'http://www.tagesschau.de/multimedia/video/video-29351~subtitle.html'
                subtitles_url = 'http://www.tagesschau.de/multimedia/video/' + str(
                    video.video_id()) + '~subtitle.html'
                subtitles_file = download_subtitles(subtitles_url,
                                                    subtitles_dir)

    listitem = xbmcgui.ListItem(path=url)
    if (subtitles_file != None):
        # the following only works in Gotham, see
        # http://forum.xbmc.org/showthread.php?tid=154805&page=7&highlight=subtitle
        listitem.setProperty('upnp:subtitle:1', subtitles_file)
        listitem.setSubtitles((subtitles_file, ))

    xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]),
                              succeeded=(url != None),
                              listitem=listitem)

elif params.get(ACTION_PARAM) == 'list_feed':
    # list video for a directory
    videos_method = getattr(provider, params[FEED_PARAM])
    url = params.get(URL_PARAM)
    if url:
        url = urllib.unquote(url) 
    else: 
        videos_method = getattr(provider, params[FEED_PARAM])
        videos = videos_method()    
        tsid = urllib.unquote(params[ID_PARAM])
        # find video with matching tsid
        for video in videos:
            if video.tsid == tsid:
                url = video.video_url(quality)
                # try to download and and convert subtitles to local SRT file
                # as of October 2014, only subtiles for complete "tagesschau" broadcasts are available
                # subtitles_url = 'http://www.tagesschau.de/multimedia/video/video-29351~subtitle.html'
                subtitles_url = 'http://www.tagesschau.de/multimedia/video/' + str(video.video_id()) + '~subtitle.html'        
                subtitles_file = download_subtitles(subtitles_url, subtitles_dir)
                
    listitem = xbmcgui.ListItem(path=url)
    if(subtitles_file != None):
        # the following only works in Gotham, see
        # http://forum.xbmc.org/showthread.php?tid=154805&page=7&highlight=subtitle
        listitem.setProperty('upnp:subtitle:1', subtitles_file)             
    xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=(url != None), listitem=listitem)

elif params.get(ACTION_PARAM) == 'list_feed':
    # list video for a directory
    videos_method = getattr(provider, params[FEED_PARAM])
    videos = videos_method()
    addVideoContentItems(videos, params[FEED_PARAM])

else: