Example #1
0
    def getSchedule(self):
        html = common.fetchPage({'link': self.__urlSchedule})
        articles = common.parseDOM(html.get("content"),
                                   name='a',
                                   attrs={'class': 'day_wrapper'})
        articles_href = common.parseDOM(html.get("content"),
                                        name='a',
                                        attrs={'class': 'day_wrapper'},
                                        ret="href")
        i = 0

        for article in articles:
            link = articles_href[i]
            i = i + 1

            day = common.parseDOM(article, name='strong', ret=False)
            if len(day) > 0:
                day = day[0].encode("utf-8")
            else:
                day = ''

            date = common.parseDOM(article, name='small', ret=False)
            if len(date) > 0:
                date = date[0].encode("utf-8")
            else:
                date = ''

            title = day + " - " + date

            parameters = {"link": link, "mode": "getScheduleDetail"}
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            self.html2ListItem(title, "", "", "", "", date, "", url, None,
                               True, False)
Example #2
0
    def getThemen(self):
        html = common.fetchPage({'link': self.topic_url})
        html_content = html.get("content")
            
        content = common.parseDOM(html_content,name='section',attrs={'class':'mod_container_list'})
        topics = common.parseDOM(content,name='section',attrs={'class':'item_wrapper'})

        for topic in topics:
            title = common.parseDOM(topic,name='h3',attrs={'class':'item_wrapper_headline.subheadline.*?'})
            title = common.replaceHTMLCodes(title[0]).encode('UTF-8')
              
            link = common.parseDOM(topic,name='a',attrs={'class':'more.service_link.service_link_more'},ret="href")
            link = common.replaceHTMLCodes(link[0]).encode('UTF-8')
                
            image = common.parseDOM(topic,name='img',ret="src")
            image = common.replaceHTMLCodes(image[0]).replace("width=395","width=500").replace("height=209.07070707071","height=265").encode('UTF-8')
                
            descs = common.parseDOM(topic,name='h4',attrs={'class':'item_title'})
            description = ""
            for desc in descs:
                description += "* "+common.replaceHTMLCodes(desc).encode('UTF-8') + "\n"
            if description == "":
                description = self.translation(30008).encode('UTF-8')

            parameters = {"link" : link,"title" : title,"banner" : image,"backdrop" : "", "mode" : "getThemenDetail"}
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            liz = self.html2ListItem(title,image,"",description,"","","",url,None,True,'false');
	def getThemen(self):
		html = common.fetchPage({'link': self.__urlTopics})
		html_content = html.get("content")

		content = common.parseDOM(html_content,name='section',attrs={})
		#topics = common.parseDOM(content,name='section',attrs={'class':'item_wrapper'})

		for topic in content:
			title = common.parseDOM(topic,name='h3',attrs={'class':'item_wrapper_headline.subheadline'})
			if title:
				title = common.replaceHTMLCodes(title[0]).encode('UTF-8')

				link = common.parseDOM(topic,name='a',attrs={'class':'more.service_link.service_link_more'},ret="href")
				link = common.replaceHTMLCodes(link[0]).encode('UTF-8')

				image = common.parseDOM(topic,name='img',ret="src")
				image = common.replaceHTMLCodes(image[0]).replace("width=395","width=500").replace("height=209.07070707071","height=265").encode('UTF-8')

				descs = common.parseDOM(topic,name='h4',attrs={'class':'item_title'})
				description = ""
				for desc in descs:
					description += "* "+common.replaceHTMLCodes(desc).encode('UTF-8') + "\n"

				parameters = {"link" : link, "mode" : "getThemenDetail"}
				url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters)
				self.html2ListItem(title,image,"",description,"","","",url,None,True, False);
	def liveStreamRestart(self, link):
		try:
			xbmcaddon.Addon('inputstream.adaptive')
		except RuntimeError:
			return

		livestream_id = link.rpartition('/')[-1]
		html = common.fetchPage({'link': link})
		bitmovinStreamId = self.getLivestreamBitmovinID(html)
		stream_info = self.getLivestreamInformation(html)

		if bitmovinStreamId:
			title	   = stream_info['title']
			image	   = stream_info['image']
			description = stream_info['description']
			duration	= stream_info['duration']
			date		= stream_info['date']
			channel	 = stream_info['channel']

			ApiKey = '2e9f11608ede41f1826488f1e23c4a8d'
			response = urllib.request.urlopen('https://playerapi-restarttv.ors.at/livestreams/%s/sections/?state=active&X-Api-Key=%s' % (bitmovinStreamId, ApiKey)) 
			response_raw = response.read().decode(response.headers.get_content_charset())
			
			section = json.loads(response_raw)
			if len(section):
				section = section[0]
				streamingURL = 'https://playerapi-restarttv.ors.at/livestreams/%s/sections/%s/manifests/hls/?startTime=%s&X-Api-Key=%s' % (bitmovinStreamId, section.get('id'), section.get('metaData').get('timestamp'), ApiKey)

				listItem = createListItem(title, image, description, duration, date, channel , streamingURL, True, False, self.defaultbackdrop, self.pluginhandle)
				listItem.setProperty('inputstreamaddon', 'inputstream.adaptive')
				listItem.setProperty('inputstream.adaptive.manifest_type', 'hls')
				self.xbmc.Player().play(streamingURL, listItem)
	def getTeaserSlideshow(self,url):
		url = urllib.parse.unquote(url)
		html = common.fetchPage({'link': url})
		container = common.parseDOM(html.get("content"),name='main',attrs={'class': "main"},ret=False)
		teasers = common.parseDOM(container,name='ul',attrs={'class': "stage-item-list.*?"},ret=False)
		items = common.parseDOM(teasers,name='li',attrs={'class': "stage-item.*?"},ret=False)

		for item in items:
			subtitle = common.parseDOM(item,name='h2',attrs={'class': "stage-item-profile-title"},ret=False)
			subtitle = common.replaceHTMLCodes(subtitle[0]).encode('UTF-8')			
			
			title = common.parseDOM(item,name='h3',attrs={'class': "stage-item-teaser-title"},ret=False)
			title = common.replaceHTMLCodes(title[0]).encode('UTF-8')
			
			figure = common.parseDOM(item,name='figure',attrs={'class':'stage-item-img'},ret=False)
			image = common.parseDOM(figure,name='img',attrs={},ret='src')
			image = common.replaceHTMLCodes(image[0]).encode('UTF-8')
			
			link = common.parseDOM(item,name='a',attrs={},ret='href')
			link = link[0].encode('UTF-8')
			
			#Reformat Title
			if subtitle != title:
				title = "%s | %s" % (subtitle,title)

			parameters = {"link" : link, "banner" : image, "mode" : "openSeries"}

			url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters)
			self.html2ListItem(title,image,"","","","","",url,None,True, False);
Example #6
0
 def getLivestreamUrl(url, quality):
     html = common.fetchPage({'link': url})
     container = common.parseDOM(html.get("content"),
                                 name='div',
                                 attrs={'class': "player_viewport.*?"})
     data_sets = common.parseDOM(container[0],
                                 name='div',
                                 attrs={},
                                 ret="data-jsb")
     for data in data_sets:
         try:
             data = common.replaceHTMLCodes(data)
             data = json.loads(data)
             if 'playlist' in data:
                 if 'videos' in data['playlist']:
                     for video_items in data['playlist']['videos']:
                         for video_sources in video_items['sources']:
                             if video_sources['quality'].lower(
                             ) == quality.lower(
                             ) and video_sources['protocol'].lower(
                             ) == "http" and video_sources[
                                     'delivery'].lower() == 'hls':
                                 return video_sources['src']
         except:
             debugLog("Error getting Livestream", "Info")
Example #7
0
def getShowByID(id):
    url = detail_infos_url % id
    html = common.fetchPage({'link': url})
    data = json.loads(html.get("content"))   
    for video in data:
        banner = video["picture"]["orig"].encode('UTF-8')
        outline = cleanText(video["description"].encode('UTF-8'))
        duration = video["duration"]

        broadcast_date_ts = float(video["broadcast_datetime"])
        broadcast_date = datetime.datetime.fromtimestamp(broadcast_date_ts)
        aired = formatAiredString(broadcast_date)
        
        title = cleanText(video["title"].encode('UTF-8'))
        channel = video["channel"]["name"].encode('UTF-8')
        description = channel+"\n"+aired+"\n\n"+outline
        
        videourl = ""
        if video["files"]["h3"]:
            if video["files"]["h3"]["url"]:
                videourl = video["files"]["h3"]["url"]
        if videourl == "":
            if video["files"]["h1"]:
                if video["files"]["h1"]["url"]:
                    videourl = video["files"]["h1"]["url"]
        if videourl != "":
            createListItem(title,banner,defaultbackdrop,description,duration,broadcast_date_ts,channel,videourl,"True",False,None)
Example #8
0
def parseJsonGridVideoContent(url):
    html = common.fetchPage({'link': url})
    data = json.loads(html.get("content"))   
    if data.has_key("rows"):
        for video in data['rows']:
            for item in video["cols"]:
                if item.has_key("content"):
                    for video_item in item['content']:
                        isVideo = False
                        name = video_item['channel'].encode('UTF-8')
                        if video_item.has_key("isVideo") and video_item["isVideo"]:
                            isVideo = video_item["isVideo"]
                            id = video_item['objectId']
                        else:
                            id = video_item['channelId']
                        title = "%s - %s" % (name,video_item['title'].encode('UTF-8'))
                        logo = video_item['previewLink']
                        poster = video_item['previewLinkVersions']['low']
                        fanart = video_item['previewLinkVersions']['hi']
                        if video_item.has_key("description"):
                            desc = video_item['description'].encode('UTF-8')
                        else:
                            desc = ""                        
                        
                        if video_item.has_key("date"):
                            date = "(%s)" % video_item['date'].encode('UTF-8')
                        else:
                            date = ""
                            
                        subline = "%s\n%s\n\n%s" % (name,desc,date)
                        addDirectory(title,poster,fanart,subline,id,"getShowByID",isVideo)
	def getLaneTopicOverview(self,url):
		html = common.fetchPage({'link': url})
		container = common.parseDOM(html.get("content"),name='section',attrs={'class': "b-list-container"},ret=False)
		
		items = common.parseDOM(container,name='div',attrs={'class': "b-lane.*?"},ret=False)

		for item in items:
			title_link = common.parseDOM(item,name='h3',attrs={'class': "title"},ret=False)
			
		
			title = common.parseDOM(title_link,name='a',attrs={},ret=False)
			title = common.replaceHTMLCodes(title[0]).encode('UTF-8')
			
			link = common.parseDOM(title_link,name='a',attrs={},ret='href')
			link = link[0].encode('UTF-8')
			link = "%s%s" % (self.__urlBase,link)
			
			desc = ""
			desc = self.formatDescription(title,"","",desc,"","")

			figure = common.parseDOM(item,name='figure',attrs={'class':'teaser-img'},ret=False)
			image = common.parseDOM(figure,name='img',attrs={},ret='src')
			image = common.replaceHTMLCodes(image[0]).encode('UTF-8')

			parameters = {"link" : link, "banner" : image, "mode" : "getArchiveDetail"}

			url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters)
			self.html2ListItem(title,image,"",desc,"","","",url,None,True, False);
Example #10
0
    def getTableResults(self,url):
        url = urllib.unquote(url)
        html = common.fetchPage({'link': url})
        items = common.parseDOM(html.get("content"),name='article',attrs={'class': "item.*?"},ret=False)

        for item in items:
            title = common.parseDOM(item,name='h4',attrs={'class': "item_title"},ret=False)
            title = common.replaceHTMLCodes(title[0]).encode('UTF-8')
            desc = common.parseDOM(item,name='div',attrs={'class': "item_description"},ret=False)
            time = ""
            date = ""
            if desc != None and len(desc) > 0:
                desc = common.replaceHTMLCodes(desc[0]).encode('UTF-8')
                date = common.parseDOM(item,name='time',attrs={'class':'meta.meta_date'},ret=False)
                date = date[0].encode('UTF-8')
                time = common.parseDOM(item,name='span',attrs={'class':'meta.meta_time'},ret=False)
                time = time[0].encode('UTF-8')
                desc = (self.translation(30009)).encode("utf-8")+' %s - %s\n%s' % (date,time,desc)
            else:
                desc = (self.translation(30008)).encode("utf-8")

            image = common.parseDOM(item,name='img',attrs={},ret='src')
            image = common.replaceHTMLCodes(image[0]).encode('UTF-8')
            link = common.parseDOM(item,name='a',attrs={},ret='href')
            link = link[0].encode('UTF-8')
            if date != "":
                title = "%s - %s" % (title,date)
                
            parameters = {"link" : link,"title" : title,"banner" : image,"backdrop" : "", "mode" : "openSeries"}
            

            
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            liz = self.html2ListItem(title,image,"",desc,"","","",url,None,True,'false');
Example #11
0
 def getCategoriesDetail(self,category,banner):
     url =  urllib.unquote(category)
     banner =  urllib.unquote(banner)
     
     html = common.fetchPage({'link': url})
     
     try:
         show = common.parseDOM(html.get("content"),name='h3',attrs={'class': 'video_headline'})
         showname = common.replaceHTMLCodes(show[0]).encode("utf-8")
     except:
         showname = ""
     playerHeader = common.parseDOM(html.get("content"),name='header',attrs={'class': 'player_header'})
     bcast_info = common.parseDOM(playerHeader,name='div',attrs={'class': 'broadcast_information'})
     
     try:
         current_duration = common.parseDOM(bcast_info,name='span',attrs={'class': 'meta.meta_duration'})
         
         current_date = common.parseDOM(bcast_info,name='span',attrs={'class': 'meta meta_date'})
         if len(current_date) > 0:
             current_date = current_date[0].encode("utf-8")
         else:
             current_date = ""
             
         current_time = common.parseDOM(bcast_info,name='span',attrs={'class': 'meta meta_time'})
         current_link = url
         if len(showname) > 0:
             current_title = "%s - %s" % (showname,current_date)       
             try:
                 current_desc = (self.translation(30009)).encode("utf-8")+' %s - %s\n'+(self.translation(30011)).encode("utf-8")+': %s' % (current_date,current_time,current_duration)
             except:
                 current_desc = self.translation(30008).encode('UTF-8');
             parameters = {"link" :  current_link,"title" :current_title,"banner" : banner,"backdrop" : "", "mode" : "openSeries"}
             url = sys.argv[0] + '?' + urllib.urlencode(parameters)
             liz = self.html2ListItem(current_title,banner,"",current_desc,"","","",url,None,True,'false');
         else:
             liz = self.html2ListItem((self.translation(30014)).encode('UTF-8'),self.defaultbanner,"","","","","","",None,True,'false');
     except:
         liz = self.html2ListItem((self.translation(30014)).encode('UTF-8'),self.defaultbanner,"","","","","","",None,True,'false');
     
     itemwrapper = common.parseDOM(html.get("content"),name='div',attrs={'class': 'base_list_wrapper.mod_latest_episodes'})
     if len(itemwrapper) > 0:
         items = common.parseDOM(itemwrapper,name='li',attrs={'class': 'base_list_item'})
         feedcount = len(items)
         i = 0
         for item in items:
             i = i+1
             duration = common.parseDOM(item,name='span',attrs={'class': 'meta.meta_duration'})
             date = common.parseDOM(item,name='span',attrs={'class': 'meta.meta_date'})
             date = date[0].encode("utf-8")
             time = common.parseDOM(item,name='span',attrs={'class': 'meta.meta_time'})
             title = common.replaceHTMLCodes(common.parseDOM(item, name='a',ret="title")[0]).encode("utf-8").replace('Sendung ', '')
             title = "%s - %s" % (title,date)
             link = common.parseDOM(item,name='a',ret="href");
             try:
                 desc = (self.translation(30009)).encode("utf-8")+" %s - %s\n"+(self.translation(30011)).encode("utf-8")+": %s" % (date,time,duration)
             except:
                 desc = self.translation(30008).encode('UTF-8');
             parameters = {"link" :  link[0],"title" :title,"banner" : banner,"backdrop" : "", "mode" : "openSeries"}
             url = sys.argv[0] + '?' + urllib.urlencode(parameters)
             liz = self.html2ListItem(title,banner,"",desc,"","","",url,None,True,'false');
Example #12
0
    def getArchiv(self,url):
        html = common.fetchPage({'link': url})
        articles = common.parseDOM(html.get("content"),name='a',attrs={'class': 'day_wrapper'})
        articles_href = common.parseDOM(html.get("content"),name='a',attrs={'class': 'day_wrapper'},ret="href")
        i = 0
            
        for article in articles:
            link = articles_href[i]
            i = i+1

            day = common.parseDOM(article,name='strong',ret=False)
            if len(day) > 0:
                day = day[0].encode("utf-8")
            else:
                day = ''
              
            date = common.parseDOM(article,name='small',ret=False)
            if len(date) > 0:
                date = date[0].encode("utf-8")
            else:
                date = ''
                
            title = day + " - " + date
            
            parameters = {"link" : link,"title" : title,"banner" : "","backdrop" : "", "mode" : "getArchivDetail"}
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            liz = self.html2ListItem(title,"","","","",date,"",url,None,True,'false');
Example #13
0
def getFile(subject, filename, folder):
    common.log(subject)

    file = findFile(subject, folder)

    if file:
        url = flickr.photos_getSizes(photo_id=file)
        url = url.find('sizes').findall('size')
        url = url[len(url) - 1]

        common.log(
            "Using: " + repr(url.attrib["label"]) + " - " +
            repr(url.attrib["source"]), 3)

        res = common.fetchPage({"link": url.attrib["source"]})

        if "encrypted" in conf and conf["encrypted"]:
            r = png.Reader(bytes=res["content"])
            width, height, pixels, meta, text = r.read()
            text = base64.b64decode(text["data"])
            saveFile(filename, text, "wb")
        else:
            saveFile(filename, res["content"], "wb")

        common.log("Done")
    else:
        common.log("Failure")
Example #14
0
def getJsonContentUrls(url):
    html = common.fetchPage({'link': url})
    data = json.loads(html.get("content"))
    links = []
    if data.has_key("content"):
        if len(data['content']) > 0:
            return data['content'];
Example #15
0
    def getBundeslandHeute(self, url, image):
        html = common.fetchPage({'link': url})
        html_content = html.get("content")

        content = common.parseDOM(
            html_content,
            name='div',
            attrs={'class': 'base_list_wrapper mod_link_list'})
        items = common.parseDOM(content,
                                name='li',
                                attrs={'class': 'base_list_item'})
        items_href = common.parseDOM(items, name='a', attrs={}, ret="href")
        items_title = common.parseDOM(items, name='h4')

        for i in range(len(items)):
            link = common.replaceHTMLCodes(items_href[i]).encode('UTF-8')
            title = items_title[i].encode('UTF-8')
            parameters = {
                "link": link,
                "title": title,
                "banner": image,
                "mode": "getSendungenDetail"
            }
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            self.html2ListItem(title, image, "", None, "", "", "", url, None,
                               True, False)
	def getArchiv(self):
		html = common.fetchPage({'link': self.__urlArchive})
		html_content = html.get("content")

		wrapper = common.parseDOM(html_content,name='main',attrs={'class':'main'})
		items = common.parseDOM(wrapper,name='article',attrs={'class':'b-topic-teaser.*?'})

		for item in items:
			subtitle = common.parseDOM(item,name='h4',attrs={'class': "sub-headline"},ret=False)
			subtitle = common.replaceHTMLCodes(subtitle[0]).encode('UTF-8')			
			
			title = common.parseDOM(item,name='h5',attrs={'class': "teaser-title.*?"},ret=False)
			title = common.replaceHTMLCodes(title[0]).encode('UTF-8')		
			
			video_count = common.parseDOM(item,name='p',attrs={'class': "topic-video-count"},ret=False)
			desc = common.replaceHTMLCodes(video_count[0]).encode('UTF-8')

			figure = common.parseDOM(item,name='figure',attrs={'class':'teaser-img'},ret=False)
			image = common.parseDOM(figure,name='img',attrs={},ret='src')
			image = common.replaceHTMLCodes(image[0]).encode('UTF-8')
			
			link = common.parseDOM(item,name='a',ret='href')
			link = link[0].encode('UTF-8')

			desc = self.formatDescription(title,"",subtitle,desc,"","")
			
			parameters = {"link" : link, "banner" : image, "mode" : "getArchiveDetail"}

			url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters)
			self.html2ListItem(title,image,"",desc,"","","",url,None,True, False);
Example #17
0
    def getHighlights(self):
        html = common.fetchPage({'link': self.__urlBase})
        html_content = html.get("content")
        teaserbox = common.parseDOM(html_content,
                                    name='a',
                                    attrs={'class': 'item_inner'})
        teaserbox_href = common.parseDOM(html_content,
                                         name='a',
                                         attrs={'class': 'item_inner'},
                                         ret="href")

        i = 0
        for teasers in teaserbox:
            link = teaserbox_href[i]
            i = i + 1
            title = common.parseDOM(teasers,
                                    name='h3',
                                    attrs={'class': 'item_title'})
            title = common.replaceHTMLCodes(title[0]).encode('UTF-8')

            desc = common.parseDOM(teasers,
                                   name='div',
                                   attrs={'class': 'item_description'})
            desc = common.replaceHTMLCodes(desc[0]).encode('UTF-8')

            image = common.parseDOM(teasers, name='img', ret="src")
            image = common.replaceHTMLCodes(image[0]).encode('UTF-8')

            parameters = {"link": link, "banner": image, "mode": "openSeries"}
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            self.html2ListItem(title, image, "", desc, "", "", "", url, None,
                               True, False)
Example #18
0
 def getLinks(self,url,banner,playlist):
     playlist.clear()
     url = str(urllib.unquote(url))
     if banner != None:
         banner = urllib.unquote(banner)
     
     html = common.fetchPage({'link': url})
     data = common.parseDOM(html.get("content"),name='div',attrs={'class': "jsb_ jsb_VideoPlaylist"},ret='data-jsb')
     
     data = data[0]
     data = common.replaceHTMLCodes(data)
     data = json.loads(data)
     
     video_items = data.get("playlist")["videos"]
     
     try:
         current_title_prefix = data.get("selected_video")["title_prefix"]
         current_title = data.get("selected_video")["title"]
         current_desc = data.get("selected_video")["description"].encode('UTF-8')
         current_duration = data.get("selected_video")["duration"]
         current_preview_img = data.get("selected_video")["preview_image_url"]
         if self.useSubtitles:
             if "subtitles" in data.get("selected_video"):
                 current_subtitles = []
                 for sub in data.get("selected_video")["subtitles"]:
                     current_subtitles.append(sub.get(u'src'))
             else:
                 current_subtitles = None
         else:
             current_subtitles = None
         current_id = data.get("selected_video")["id"]
         current_videourl = self.getVideoUrl(data.get("selected_video")["sources"]);
     except Exception, e:
         current_subtitles = None
         print e
Example #19
0
    def openArchiv(self,url):
        url =  urllib.unquote(url)
        html = common.fetchPage({'link': url})
        teasers = common.parseDOM(html.get("content"),name='a',attrs={'class': 'item_inner.clearfix'})
        teasers_href = common.parseDOM(html.get("content"),name='a',attrs={'class': 'item_inner.clearfix'},ret="href")

        i = 0
        for teaser in teasers:
            link = teasers_href[i]
            i = i+1
            
            title = common.parseDOM(teaser,name='h4',attrs={'class': "item_title"},ret=False)
            title = common.replaceHTMLCodes(title[0]).encode("utf-8")
            
            time = common.parseDOM(teaser,name='span',attrs={'class': "meta.meta_time"},ret=False)
            time = common.replaceHTMLCodes(time[0]).encode("utf-8")
            
            title = "["+time+"] "+title
            
            description = common.parseDOM(teaser,name='div',attrs={'class': "item_description"},ret=False)
            if len(description) > 0 :
                description = common.replaceHTMLCodes(description[0])
            else:
                description = self.translation(30008).encode('UTF-8')
                
            banner = common.parseDOM(teaser,name='img',ret='src')
            banner = common.replaceHTMLCodes(banner[1]).encode("utf-8")
            
            banner = common.parseDOM(teaser,name='img',ret='src')
            banner = common.replaceHTMLCodes(banner[1]).encode("utf-8")
            
            parameters = {"link" : link,"title" : title,"banner" : banner,"backdrop" : self.defaultbackdrop, "mode" : "openSeries"}
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            liz = self.html2ListItem(title,banner,"",description,"","","",url,None,True,'false');
Example #20
0
def getFile(subject, filename, folder):
    common.log(subject)

    file = findFile(subject, folder)

    if file:
        url = flickr.photos_getSizes(photo_id=file)
        url = url.find('sizes').findall('size')
        url = url[len(url) -1]

        common.log("Using: " + repr(url.attrib["label"]) + " - " + repr(url.attrib["source"]), 3)
        
        res = common.fetchPage({"link": url.attrib["source"]})

        if "encrypted" in conf and conf["encrypted"]:
            r=png.Reader(bytes=res["content"])
            width, height, pixels, meta, text = r.read()
            text = base64.b64decode(text["data"])
            saveFile(filename, text, "wb")
        else:
            saveFile(filename, res["content"], "wb")

        common.log("Done")
    else:
        common.log("Failure")
Example #21
0
def getCategory(category):
    categoryHTML = xbmc_common.fetchPage(
        {"link": "https://sub.media/c/" + category + "/"})
    category = xbmc_common.parseDOM(categoryHTML['content'],
                                    'main',
                                    attrs={'id': 'main'})
    articles = xbmc_common.parseDOM(category, 'article')

    for article in articles:
        img = xbmc_common.parseDOM(article, 'img', ret='src')
        title = xbmc_common.parseDOM(article, 'a', ret='title')
        articleUrl = xbmc_common.parseDOM(article, 'a', ret='ref')
        desc = xbmc_common.parseDOM(article, 'p')

        urlVideo = getVideoUrl(articleUrl[0])

        # print title[0].encode('utf-8')
        # print urlVideo
        if len(urlVideo) > 0:
            li = xbmcgui.ListItem(title[0].encode('utf-8'), iconImage=img[0])
            addDirectoryItem(handle=plugin.handle, url=urlVideo, listitem=li)
        else:
            #http://kodi.wiki/view/Add-on:YouTube
            print title[0].encode('utf-8')
            print urlVideo
            print "failed"
Example #22
0
def getJSONVideos(url):
    html = common.fetchPage({'link': url})
    data = json.loads(html.get("content"))   
    if data.has_key("videos"):
        for video in data['videos']:
            image = video["picture"]["orig"].encode('UTF-8')
            desc = cleanText(video["description"].encode('UTF-8'))
            duration = video["duration"]
            date = video["broadcast_date"].encode('UTF-8')
            time = video["broadcast_time"].encode('UTF-8')
            utime = video["broadcast_datetime"].encode('UTF-8')
            
            day = datetime.datetime.fromtimestamp(float(utime)).strftime('%d').lstrip('0')
            
            hour = datetime.datetime.fromtimestamp(float(utime)).strftime('%H').lstrip('0')
            min = datetime.datetime.fromtimestamp(float(utime)).strftime('%M')
            weekday = datetime.datetime.fromtimestamp(float(utime)).strftime('%A')
            weekday = translateDay(weekday)
            
            year = datetime.datetime.fromtimestamp(float(utime)).strftime('%Y')
            month = datetime.datetime.fromtimestamp(float(utime)).strftime('%m')
            aired = weekday+", "+day+"."+month+"."+year+" ("+hour+":"+min+")"
            channel = video["channel"]["name"].encode('UTF-8')
            title = cleanText(video["title"].encode('UTF-8'))
            videourl = ""
            if video["files"]["h3"]:
                if video["files"]["h3"]["url"]:
                    videourl = video["files"]["h3"]["url"]
            if videourl == "":
                if video["files"]["h1"]:
                    if video["files"]["h1"]["url"]:
                        videourl = video["files"]["h1"]["url"]
            if videourl != "":
                createListItem(title,image,channel+"\n"+aired+"\n"+desc,duration,date,channel,videourl,"True",False,None)
Example #23
0
    def getCategories(self):
        html = common.fetchPage({'link': self.__urlShows})
        html_content = html.get("content")

        content = common.parseDOM(html_content,
                                  name='div',
                                  attrs={'class': 'region_main'})
        items = common.parseDOM(content,
                                name='article',
                                attrs={'class': 'item'})

        for item in items:
            link = common.parseDOM(item,
                                   name='a',
                                   attrs={'class': 'item_inner clearfix'},
                                   ret="href")
            link = common.replaceHTMLCodes(link[0]).encode('UTF-8')
            title = common.parseDOM(item,
                                    name='h4',
                                    attrs={'class': 'item_title'})
            title = common.replaceHTMLCodes(title[0]).encode('UTF-8').replace(
                "[", "").replace("]", "")

            image = common.parseDOM(item, name='img', ret="src")
            image = common.replaceHTMLCodes(image[0]).encode('UTF-8')

            parameters = {
                "link": link,
                "title": title,
                "banner": image,
                "mode": "getSendungenDetail"
            }
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            self.html2ListItem(title, image, "", None, "", "", "", url, None,
                               True, False)
Example #24
0
 def getZIB(self,baseimage):
     url = 'http://tvthek.orf.at/programs/genre/ZIB/1';
     html = common.fetchPage({'link': url})
     html_content = html.get("content")
     
     content = common.parseDOM(html_content,name='div',attrs={'class':'base_list_wrapper mod_results_list'})
     items = common.parseDOM( content ,name='li',attrs={'class':'base_list_item jsb_ jsb_ToggleButton results_item'})
     
     for item in items:
         title = common.parseDOM(item,name='h4')
         if len(title) > 0:
             title = title[0].encode('UTF-8')
             print title
             item_href = common.parseDOM(item,name='a',attrs={'class':'base_list_item_inner.*?'},ret="href")
             image_container = common.parseDOM(item,name='figure',attrs={'class':'episode_image'},ret="href")
             desc = self.translation(30008).encode('UTF-8')
             image = common.parseDOM(item,name='img',attrs={},ret="src")
             print len(image)
             if len(image) > 0:
                 image = common.replaceHTMLCodes(image[0]).encode('UTF-8').replace("height=180","height=265").replace("width=320","width=500")
             else:
                 image = baseimage
                 
             if len(item_href) > 0:
                 link = common.replaceHTMLCodes(item_href[0]).encode('UTF-8')
                 parameters = {"link" : link,"title" : title,"banner" : image,"backdrop" : "", "mode" : "getSendungenDetail"}
                 url = sys.argv[0] + '?' + urllib.urlencode(parameters)
                 liz = self.html2ListItem(title,image,"",desc,"","","",url,None,True,'false');
Example #25
0
    def getCategories(self):
        html = common.fetchPage({'link': self.base_url})
        html_content = html.get("content")
        
        content = common.parseDOM(html_content,name='div',attrs={'class':'mod_carousel'})
        items = common.parseDOM(content,name='a',attrs={'class':'carousel_item_link'})
        items_href = common.parseDOM(content,name='a',attrs={'class':'carousel_item_link'},ret="href")
        
        i = 0
        for item in items:
            link = common.replaceHTMLCodes(items_href[i]).encode('UTF-8')
            i = i + 1
            title = self.programUrlTitle(link).encode('UTF-8')
            if title.lower().strip() == "bundesland heute":
                image = common.parseDOM(item,name='img',ret="src")
                image = common.replaceHTMLCodes(image[0]).replace("height=56","height=280").replace("width=100","width=500").encode('UTF-8')
                self.getBundeslandHeute(link,image)
            if title.lower().strip() == "zib":
                image = common.parseDOM(item,name='img',ret="src")
                image = common.replaceHTMLCodes(image[0]).replace("height=56","height=280").replace("width=100","width=500").encode('UTF-8')
                self.getZIB(image)
            else:
                image = common.parseDOM(item,name='img',ret="src")
                image = common.replaceHTMLCodes(image[0]).replace("height=56","height=280").replace("width=100","width=500").encode('UTF-8')

                desc = self.translation(30008).encode('UTF-8')
                if title.lower().strip() != "bundesland heute":
                    parameters = {"link" : link,"title" : title,"banner" : image,"backdrop" : "", "mode" : "getSendungenDetail"}
                    url = sys.argv[0] + '?' + urllib.urlencode(parameters)
                    liz = self.html2ListItem(title,image,"",desc,"","","",url,None,True,'false');
	def getLiveStreams(self):
		html = common.fetchPage({'link': self.__urlBase})
		#html = common.fetchPage({'link': "https://office.lo-fi.at/tmp/"})
		wrapper = common.parseDOM(html.get("content"),name='main',attrs={'class': 'main'})
		section = common.parseDOM(wrapper,name='section',attrs={'class': 'b-live-program.*?'})
		items = common.parseDOM(section,name='li',attrs={'class': 'channel orf.*?'})

		for item in items:		
			channel = common.parseDOM(item,name='img',attrs={'class': 'channel-logo'},ret="alt")
			channel = common.replaceHTMLCodes(channel[0]).encode('UTF-8')

			
			bundesland_article = common.parseDOM(item,name='li',attrs={'class': '.*?is-bundesland-heute.*?'},ret='data-jsb')	
			article = common.parseDOM(item,name='article',attrs={'class': 'b-livestream-teaser.*?'})
			if not len(bundesland_article) and len(article):
				figure = common.parseDOM(article,name='figure',attrs={'class':'teaser-img'},ret=False)
				image = common.parseDOM(figure,name='img',attrs={},ret='data-src')
				image = common.replaceHTMLCodes(image[0]).encode('UTF-8')

				time = common.parseDOM(article,name='h4',attrs={'class': 'time'},ret=False)
				time = common.replaceHTMLCodes(time[0]).encode('UTF-8').replace("Uhr","").replace(".",":").strip()
				time = common.stripTags(time).encode('UTF-8')
	
				title = common.parseDOM(article,name='h4',attrs={'class': 'livestream-title.*?'})
				title = common.replaceHTMLCodes(title[0]).encode('UTF-8')

				link = common.parseDOM(item,name='a',attrs={'class': 'js-link-box'},ret="href")
				link = common.replaceHTMLCodes(link[0]).encode('UTF-8')
				
				data = common.parseDOM(item,name='a',attrs={'class': 'js-link-box'},ret="data-jsb")
				data = common.replaceHTMLCodes(data[0]).encode('UTF-8')
				data = json.loads(data)
			
				online = common.parseDOM(article,name='span',attrs={'class': 'status-online'})
				if len(online):
					online = True
				else:
					online = False				
						
				restart = common.parseDOM(article,name='span',attrs={'class': 'is-restartable'})
				if len(restart):
					restart = True
				else:
					restart = False
					
				self.buildLivestream(title,link,time,restart,channel,image,online)
			elif len(bundesland_article):
				bundesland_data = common.replaceHTMLCodes(bundesland_article[0]).encode('UTF-8')
				bundesland_data = json.loads(bundesland_data)
						
				for bundesland_item_key in bundesland_data:
					bundesland_item = bundesland_data.get(bundesland_item_key)
					bundesland_title = bundesland_item.get('title').encode('UTF-8')
					bundesland_image = bundesland_item.get('img').encode('UTF-8')
					bundesland_link = bundesland_item.get('url').encode('UTF-8')
							
					self.buildLivestream(bundesland_title,bundesland_link,"",True,channel,bundesland_image,True)
Example #27
0
def getDynamicMenuItems():
    json_links = getJsonContentUrls(main_url)
    for json_link in json_links:
        url = "%s%s" % (base_url,json_link['url'])
        html = common.fetchPage({'link':url })
        data = json.loads(html.get("content"))   
        if data.has_key("headingText") and data.has_key("rows"):
            title = data["headingText"].encode('UTF-8')
            addDirectory(title,defaultlogo,"","",url,"getDynamicVideo")
	def getLaneCategories(self):
		html = common.fetchPage({'link': self.__urlBase})
		items = common.parseDOM(html.get("content"),name='div',attrs={'class': ".*?jsb_LaneLoad.*?"},ret='data-jsb')
		
		for item in items:
			data = common.replaceHTMLCodes(item).encode('UTF-8')	
			json_data = json.loads(data)
			if "url" in json_data:
				lane_url = "%s%s" % (self.__urlBase,json_data.get('url'))
				self.getLaneItems(lane_url)
Example #29
0
    def getArchiveDetail(self, url):
        url = urllib.unquote(url)
        html = common.fetchPage({'link': url})
        html_content = html.get("content")

        content = common.parseDOM(html_content,
                                  name='section',
                                  attrs={'class': 'mod_container_list.*?'})

        topics = common.parseDOM(content,
                                 name='article',
                                 attrs={'class': 'item.*?'})

        for topic in topics:
            title = common.parseDOM(topic,
                                    name='h4',
                                    attrs={'class': 'item_title'})
            title = common.replaceHTMLCodes(title[0]).encode('UTF-8')

            link = common.parseDOM(topic, name='a', ret="href")
            link = common.replaceHTMLCodes(link[0]).encode('UTF-8')

            image = common.parseDOM(topic, name='img', ret="src")
            if len(image) > 0:
                image = common.replaceHTMLCodes(image[0]).encode('UTF-8')
            else:
                image = self.defaultbanner

            desc = common.parseDOM(topic,
                                   name='div',
                                   attrs={'class': 'item_description'})
            if len(desc) > 0:
                desc = common.replaceHTMLCodes(desc[0]).encode('UTF-8')
            else:
                desc = ''

            date = common.parseDOM(topic, name='time')
            date = common.replaceHTMLCodes(date[0]).encode('UTF-8')

            time = common.parseDOM(topic,
                                   name='span',
                                   attrs={'class': 'meta.meta_duration'})
            time = common.replaceHTMLCodes(time[0]).encode('UTF-8')

            desc = "%s - (%s) \n%s" % (str(date), str(time).strip(), str(desc))

            parameters = {
                "link": link,
                "title": title,
                "banner": image,
                "mode": "openSeries"
            }
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            self.html2ListItem(title, image, "", desc, "", "", "", url, None,
                               True, False)
	def getLaneItems(self,url):
		category = False
		html = common.fetchPage({'link': url})
		items = common.parseDOM(html.get("content"),name='article',attrs={'class': "b-teaser"},ret=False)
		
		
		
		if len(items) < 1:
			self.getLaneTeasers(html)
		else:
			lane_title = common.parseDOM(html.get("content"),name='h3',attrs={'class': "title"},ret=False)
			lane_title = common.replaceHTMLCodes(lane_title[0]).encode('UTF-8')
			lane_title = common.stripTags(lane_title)
			for item in items:
				subtitle = common.parseDOM(item,name='h4',attrs={'class': "profile"},ret=False)
				subtitle = common.replaceHTMLCodes(subtitle[0]).encode('UTF-8')			
					
				title = common.parseDOM(item,name='h5',attrs={'class': "teaser-title.*?"},ret=False)
				title = common.replaceHTMLCodes(title[0]).encode('UTF-8')
				title = "[%s] %s" % (lane_title,title)
					
				desc = common.parseDOM(item,name='p',attrs={'class': "description.*?"},ret=False)
				if len(desc):
					desc = common.replaceHTMLCodes(desc[0]).encode('UTF-8')
				else:
					desc = ""
					
				channel = common.parseDOM(item,name='p',attrs={'class': "channel"},ret=False)
				if len(channel):
					channel = common.replaceHTMLCodes(channel[0]).encode('UTF-8')
				else:
					channel = ""
				date = common.parseDOM(item,name='span',attrs={'class':'date'},ret=False)
				date = date[0].encode('UTF-8')
				
				time = common.parseDOM(item,name='span',attrs={'class':'time'},ret=False)
				time = time[0].encode('UTF-8')

				figure = common.parseDOM(item,name='figure',attrs={'class':'teaser-img'},ret=False)
				image = common.parseDOM(figure,name='img',attrs={},ret='src')
				image = common.replaceHTMLCodes(image[0]).encode('UTF-8')
				
				link = common.parseDOM(item,name='a',attrs={'class':'teaser-link.*?'},ret='href')
				link = link[0].encode('UTF-8')
					
				date_prefix = self.translation(30009).encode("utf-8")
				
				if date != "":
					title = "%s - %s" % (title,date)
					
				desc = self.formatDescription(title,channel,subtitle,desc,date,time)

				parameters = {"link" : link, "banner" : image, "mode" : "openSeries"}
				url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters)
				self.html2ListItem(title,image,"", desc,"","","",url,None,True, False);
Example #31
0
    def openArchiv(self, url):
        url = urllib.unquote(url)
        html = common.fetchPage({'link': url})
        teasers = common.parseDOM(html.get("content"),
                                  name='a',
                                  attrs={'class': 'item_inner.clearfix'})
        teasers_href = common.parseDOM(html.get("content"),
                                       name='a',
                                       attrs={'class': 'item_inner.clearfix'},
                                       ret="href")

        i = 0
        for teaser in teasers:
            link = teasers_href[i]
            i = i + 1

            title = common.parseDOM(teaser,
                                    name='h4',
                                    attrs={'class': "item_title"},
                                    ret=False)
            title = common.replaceHTMLCodes(title[0]).encode("utf-8")

            time = common.parseDOM(teaser,
                                   name='span',
                                   attrs={'class': "meta.meta_time"},
                                   ret=False)
            time = common.replaceHTMLCodes(time[0]).encode("utf-8")

            title = "[" + time + "] " + title

            description = common.parseDOM(teaser,
                                          name='div',
                                          attrs={'class': "item_description"},
                                          ret=False)
            if len(description) > 0:
                description = common.replaceHTMLCodes(description[0])
            else:
                description = self.translation(30008).encode('UTF-8')

            banner = common.parseDOM(teaser, name='img', ret='src')
            banner = common.replaceHTMLCodes(banner[1]).encode("utf-8")

            banner = common.parseDOM(teaser, name='img', ret='src')
            banner = common.replaceHTMLCodes(banner[1]).encode("utf-8")

            parameters = {
                "link": link,
                "title": title,
                "banner": banner,
                "backdrop": self.defaultbackdrop,
                "mode": "openSeries"
            }
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            liz = self.html2ListItem(title, banner, "", description, "", "",
                                     "", url, None, True, 'false')
Example #32
0
    def getZIB(self, baseimage):
        url = 'http://tvthek.orf.at/programs/genre/ZIB/1'
        html = common.fetchPage({'link': url})
        html_content = html.get("content")

        content = common.parseDOM(
            html_content,
            name='div',
            attrs={'class': 'base_list_wrapper mod_results_list'})
        items = common.parseDOM(
            content,
            name='li',
            attrs={
                'class': 'base_list_item jsb_ jsb_ToggleButton results_item'
            })

        for item in items:
            title = common.parseDOM(item, name='h4')
            if len(title) > 0:
                title = title[0].encode('UTF-8')
                print title
                item_href = common.parseDOM(
                    item,
                    name='a',
                    attrs={'class': 'base_list_item_inner.*?'},
                    ret="href")
                image_container = common.parseDOM(
                    item,
                    name='figure',
                    attrs={'class': 'episode_image'},
                    ret="href")
                desc = self.translation(30008).encode('UTF-8')
                image = common.parseDOM(item, name='img', attrs={}, ret="src")
                print len(image)
                if len(image) > 0:
                    image = common.replaceHTMLCodes(
                        image[0]).encode('UTF-8').replace(
                            "height=180",
                            "height=265").replace("width=320", "width=500")
                else:
                    image = baseimage

                if len(item_href) > 0:
                    link = common.replaceHTMLCodes(
                        item_href[0]).encode('UTF-8')
                    parameters = {
                        "link": link,
                        "title": title,
                        "banner": image,
                        "backdrop": "",
                        "mode": "getSendungenDetail"
                    }
                    url = sys.argv[0] + '?' + urllib.urlencode(parameters)
                    liz = self.html2ListItem(title, image, "", desc, "", "",
                                             "", url, None, True, 'false')
Example #33
0
    def getTableResults(self, url):
        url = urllib.unquote(url)
        html = common.fetchPage({'link': url})
        items = common.parseDOM(html.get("content"),
                                name='article',
                                attrs={'class': "item.*?"},
                                ret=False)

        for item in items:
            title = common.parseDOM(item,
                                    name='h4',
                                    attrs={'class': "item_title"},
                                    ret=False)
            title = common.replaceHTMLCodes(title[0]).encode('UTF-8')
            desc = common.parseDOM(item,
                                   name='div',
                                   attrs={'class': "item_description"},
                                   ret=False)
            time = ""
            date = ""
            if desc != None and len(desc) > 0:
                desc = common.replaceHTMLCodes(desc[0]).encode('UTF-8')
                date = common.parseDOM(item,
                                       name='time',
                                       attrs={'class': 'meta.meta_date'},
                                       ret=False)
                date = date[0].encode('UTF-8')
                time = common.parseDOM(item,
                                       name='span',
                                       attrs={'class': 'meta.meta_time'},
                                       ret=False)
                time = time[0].encode('UTF-8')
                desc = (self.translation(30009)
                        ).encode("utf-8") + ' %s - %s\n%s' % (date, time, desc)
            else:
                desc = (self.translation(30008)).encode("utf-8")

            image = common.parseDOM(item, name='img', attrs={}, ret='src')
            image = common.replaceHTMLCodes(image[0]).encode('UTF-8')
            link = common.parseDOM(item, name='a', attrs={}, ret='href')
            link = link[0].encode('UTF-8')
            if date != "":
                title = "%s - %s" % (title, date)

            parameters = {
                "link": link,
                "title": title,
                "banner": image,
                "backdrop": "",
                "mode": "openSeries"
            }

            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            liz = self.html2ListItem(title, image, "", desc, "", "", "", url,
                                     None, True, 'false')
Example #34
0
def getVideoUrl(articleUrl):
    articleHTML = xbmc_common.fetchPage({"link": articleUrl})
    regex = r"href=\"(.+?mp4)\""
    content = articleHTML['content']
    matches = re.finditer(regex, content)
    for matchNum, match in enumerate(matches):
        matchNum = matchNum + 1
        for groupNum in range(0, len(match.groups())):
            groupNum = groupNum + 1
            return content[match.start(groupNum):match.end(groupNum)]
    return ''
Example #35
0
def getJSONSendungen(url):
    html = common.fetchPage({'link': url})
    data = json.loads(html.get("content"))   
    for show in data:
        try:
            image = show["logo"]["orig"].encode('UTF-8')
        except:
            image = ""
        id = show["id"]
        title = cleanText(show["name"].encode('UTF-8'))
        addDirectory(title,image,"",id,"getShowByID")
Example #36
0
    def getLiveStreams(self):
        liveurls = {}
        
        liveurls['ORF1'] = "http://apasfiisl.apa.at/ipad/orf1_"+self.videoQuality.lower()+"/orf.sdp/playlist.m3u8"
        liveurls['ORF2'] = "http://apasfiisl.apa.at/ipad/orf2_"+self.videoQuality.lower()+"/orf.sdp/playlist.m3u8"
        liveurls['ORF3'] = "http://apasfiisl.apa.at/ipad/orf3_"+self.videoQuality.lower()+"/orf.sdp/playlist.m3u8"
        liveurls['ORF'] = "http://apasfiisl.apa.at/ipad/orfs_"+self.videoQuality.lower()+"/orf.sdp/playlist.m3u8"
        
        channelnames = {}
        channelnames['ORF1'] = "ORF 1"
        channelnames['ORF2'] = "ORF 2"
        channelnames['ORF3'] = "ORF III"
        channelnames['ORF'] = "ORF Sport+"
            
        html = common.fetchPage({'link': self.__urlLive})
        wrapper = common.parseDOM(html.get("content"),name='div',attrs={'class': 'base_list_wrapper mod_epg'})
        items = common.parseDOM(wrapper[0],name='li',attrs={'class': 'base_list_item.program.*?'})
        items_class = common.parseDOM(wrapper[0],name='li',attrs={'class': 'base_list_item.program.*?'},ret="class")
        i = 0
        for item in items:
            program = items_class[i].split(" ")[2].encode('UTF-8').upper()
            i += 1
            if channelnames[program]:                    
                banner = common.parseDOM(item,name='img',ret="src")
                banner = common.replaceHTMLCodes(banner[0]).encode('UTF-8')
                  
                title = common.parseDOM(item,name='h4')
                title = common.replaceHTMLCodes(title[0]).encode('UTF-8')
                   
                time = common.parseDOM(item,name='span',attrs={'class': 'meta.meta_time'})
                time = common.replaceHTMLCodes(time[0]).encode('UTF-8').replace("Uhr","").replace(".",":").strip()

                if self.getBroadcastState(time):
                    state = (self.translation(30019)).encode("utf-8")
                    state_short = "Online"
                else:
                    state = (self.translation(30020)).encode("utf-8")
                    state_short = "Offline"
                
                link = liveurls[program]
                final_title = "[%s] - %s (%s)" % (channelnames[program],title,time)
                liz = self.html2ListItem(final_title,banner,"",state,time,program,program,link,None,False, True)
                child_list = common.parseDOM(item,name='li',attrs={'class': 'base_list_item'})
                for child_list_item in child_list:
                    child_list_title = common.parseDOM(child_list_item,name='h4')
                    child_list_title = common.replaceHTMLCodes(child_list_title[0]).encode('UTF-8')
                    child_list_link = common.parseDOM(child_list_item,name='a',attrs={'class': 'base_list_item_inner'},ret="href")
                    child_list_link = common.replaceHTMLCodes(child_list_link[0])
                    child_list_time = common.parseDOM(child_list_item,name='span',attrs={'class': 'meta.meta_time'})
                    child_list_time = common.replaceHTMLCodes(child_list_time[0]).encode('UTF-8').replace("Uhr","").replace(".",":").strip()
                    if child_list_time == time and child_list_title != title:
                        child_list_streaming_url = self.getLivestreamUrl(child_list_link,self.videoQuality)
                        child_list_final_title = "[%s] - %s (%s)" % (channelnames[program],child_list_title,child_list_time)
                        liz = self.html2ListItem(child_list_final_title,banner,"",state,time,program,program,child_list_streaming_url,None,False, True)
Example #37
0
    def getCategories(self):
        html = common.fetchPage({'link': self.base_url})
        html_content = html.get("content")

        content = common.parseDOM(html_content,
                                  name='div',
                                  attrs={'class': 'mod_carousel'})
        items = common.parseDOM(content,
                                name='a',
                                attrs={'class': 'carousel_item_link'})
        items_href = common.parseDOM(content,
                                     name='a',
                                     attrs={'class': 'carousel_item_link'},
                                     ret="href")

        i = 0
        for item in items:
            link = common.replaceHTMLCodes(items_href[i]).encode('UTF-8')
            i = i + 1
            title = self.programUrlTitle(link).encode('UTF-8')
            if title.lower().strip() == "bundesland heute":
                image = common.parseDOM(item, name='img', ret="src")
                image = common.replaceHTMLCodes(image[0]).replace(
                    "height=56",
                    "height=280").replace("width=100",
                                          "width=500").encode('UTF-8')
                self.getBundeslandHeute(link, image)
            if title.lower().strip() == "zib":
                image = common.parseDOM(item, name='img', ret="src")
                image = common.replaceHTMLCodes(image[0]).replace(
                    "height=56",
                    "height=280").replace("width=100",
                                          "width=500").encode('UTF-8')
                self.getZIB(image)
            else:
                image = common.parseDOM(item, name='img', ret="src")
                image = common.replaceHTMLCodes(image[0]).replace(
                    "height=56",
                    "height=280").replace("width=100",
                                          "width=500").encode('UTF-8')

                desc = self.translation(30008).encode('UTF-8')
                if title.lower().strip() != "bundesland heute":
                    parameters = {
                        "link": link,
                        "title": title,
                        "banner": image,
                        "backdrop": "",
                        "mode": "getSendungenDetail"
                    }
                    url = sys.argv[0] + '?' + urllib.urlencode(parameters)
                    liz = self.html2ListItem(title, image, "", desc, "", "",
                                             "", url, None, True, 'false')
	def openArchiv(self,url):
		url = urllib.parse.unquote(url)
		html = common.fetchPage({'link': url})
		container = common.parseDOM(html.get("content"),name='main',attrs={'class': "main"},ret=False)
		teasers = common.parseDOM(container,name='div',attrs={'class': "b-schedule-list"},ret=False)
		items = common.parseDOM(teasers,name='article',attrs={'class': "b-schedule-episode.*?"},ret=False)
		
		date = common.parseDOM(teasers,name='h2',attrs={'class':'day-title.*?'},ret=False)
		if len(date):
			date = date[0].encode('UTF-8')
		else:
			date = ""

		for item in items:	
			title = common.parseDOM(item,name='h4',attrs={'class': "item-title.*?"},ret=False)
			title = common.replaceHTMLCodes(title[0]).encode('UTF-8')
			
			desc = common.parseDOM(item,name='div',attrs={'class': "item-description.*?"},ret=False)
			if len(desc):
				desc = common.replaceHTMLCodes(desc[0]).encode('UTF-8')
				desc = common.stripTags(desc)
			else:
				desc = ""
			
			channel = common.parseDOM(item,name='span',attrs={'class': "small-information.meta.meta-channel-name"},ret=False)
			if len(channel):
				channel = common.replaceHTMLCodes(channel[0]).encode('UTF-8')
			else:
				channel = ""
			
			time = common.parseDOM(item,name='span',attrs={'class':'meta.meta-time'},ret=False)
			time = time[0].encode('UTF-8')
			
			title = "[%s] %s" % (time,title)
			
			subtitle = time

			figure = common.parseDOM(item,name='figure',attrs={'class':'episode-image'},ret=False)
			image = common.parseDOM(figure,name='img',attrs={},ret='src')
			image = common.replaceHTMLCodes(image[0]).encode('UTF-8')
			
			link = common.parseDOM(item,name='a',attrs={'class':'episode-content'},ret='href')
			link = link[0].encode('UTF-8')

			desc = self.formatDescription(title,channel,subtitle,desc,date,time)
			
			parameters = {"link" : link, "banner" : image, "mode" : "openSeries"}

			url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters)
			self.html2ListItem(title,image,"",desc,"","","",url,None,True, False);
Example #39
0
def getPage(url):
    if not url.startswith("/") and not url.startswith("http://"):
        url = "/" + url

    result = common.fetchPage({"link": url})

    if result["status"] == 200:
        return result["content"]

    if result["status"] == 500:
        common.log("redirect url: %s" % result["new_url"])
        common.log("header: %s" % result["header"])
        common.log("content: %s" % result["content"])
        return None
Example #40
0
def getPage(url):
  if not url.startswith("/") and not url.startswith("http://"):
    url = "/" + url

  result = common.fetchPage({ "link": url })

  if result["status"] == 200:
    return result["content"]

  if result["status"] == 500:
    common.log("redirect url: %s" %result["new_url"])
    common.log("header: %s" %result["header"])
    common.log("content: %s" %result["content"])
    return None
Example #41
0
    def getThemen(self):
        html = common.fetchPage({'link': self.topic_url})
        html_content = html.get("content")

        content = common.parseDOM(html_content,
                                  name='section',
                                  attrs={'class': 'mod_container_list'})
        topics = common.parseDOM(content,
                                 name='section',
                                 attrs={'class': 'item_wrapper'})

        for topic in topics:
            title = common.parseDOM(
                topic,
                name='h3',
                attrs={'class': 'item_wrapper_headline.subheadline.*?'})
            title = common.replaceHTMLCodes(title[0]).encode('UTF-8')

            link = common.parseDOM(
                topic,
                name='a',
                attrs={'class': 'more.service_link.service_link_more'},
                ret="href")
            link = common.replaceHTMLCodes(link[0]).encode('UTF-8')

            image = common.parseDOM(topic, name='img', ret="src")
            image = common.replaceHTMLCodes(image[0]).replace(
                "width=395", "width=500").replace("height=209.07070707071",
                                                  "height=265").encode('UTF-8')

            descs = common.parseDOM(topic,
                                    name='h4',
                                    attrs={'class': 'item_title'})
            description = ""
            for desc in descs:
                description += "* " + common.replaceHTMLCodes(desc).encode(
                    'UTF-8') + "\n"
            if description == "":
                description = self.translation(30008).encode('UTF-8')

            parameters = {
                "link": link,
                "title": title,
                "banner": image,
                "backdrop": "",
                "mode": "getThemenDetail"
            }
            url = sys.argv[0] + '?' + urllib.urlencode(parameters)
            liz = self.html2ListItem(title, image, "", description, "", "", "",
                                     url, None, True, 'false')
Example #42
0
def parseJsonDirectoryContent(url):
    html = common.fetchPage({'link': url})
    data = json.loads(html.get("content"))   
    if data.has_key("formatOverviewItems"):
        for video in data['formatOverviewItems']:
            for item in video["blocks"]:
                name = item['channel'].encode('UTF-8')
                if name != "":
                    id = item['channelId']
                    logo = "%s%s" % (base_url,video['channelLogoImg'])
                    poster = "%s%s" % (base_url,video['formatOverviewItemImgVersions']['low'])
                    fanart = "%s%s" % (base_url,video['formatOverviewItemImgVersions']['hi'])
                    desc = "%s \n%s: %s \n\n(%s)" % (name,item['label'].encode('UTF-8'),item['title'].encode('UTF-8'),item['date'].encode('UTF-8'))
                    addDirectory(name,fanart,fanart,desc,id,"getShowByID")            
Example #43
0
 def getLivestreamUrl(self,url,quality):
     html = common.fetchPage({'link': url})
     container = common.parseDOM(html.get("content"),name='div',attrs={'class': "player_viewport.*?"})
     data_sets = common.parseDOM(container[0],name='div',attrs={},ret="data-jsb")
     for data in data_sets:
         try:
             data = common.replaceHTMLCodes(data)
             data = json.loads(data)
             if data['playlist']['videos']:
                 for video_items in data['playlist']['videos']:
                     for video_sources in video_items['sources']:
                         if video_sources['quality'].lower() == quality.lower() and video_sources['protocol'].lower() == "http" and video_sources['delivery'].lower() == 'hls':
                             return video_sources['src']
         except:
             continue
Example #44
0
def getFile(subject, filename, folder):
    common.log(subject)

    file = False
    page = 1
    while not file:
        photos = flickr.photosets_getPhotos(photoset_id=folder,
                                            per_page=500,
                                            page=page)
        photos = photos.find("photoset")
        for s in photos.findall('photo'):
            title = s.attrib["title"]
            common.log("Found title: " + repr(title), 2)
            if title == subject:
                common.log("Found title2: " + repr(title), 0)
                file = s.attrib["id"]
                break
        if int(photos.attrib["total"]) > page:
            page += 1
            common.log("Trying page: " + repr(page) + " - " +
                       repr(photos.attrib))
        else:
            common.log("Error. found nothing:" + repr(photos))
            common.log("Error. found nothing:" + repr(photos.attrib))
            break

    if file:
        url = flickr.photos_getSizes(photo_id=file)
        url = url.find('sizes').findall('size')
        url = url[len(url) - 1]

        common.log(
            "Using: " + repr(url.attrib["label"]) + " - " +
            repr(url.attrib["source"]), 3)

        res = common.fetchPage({"link": url.attrib["source"]})

        if "encrypted" in conf and conf["encrypted"]:
            r = png.Reader(bytes=res["content"])
            width, height, pixels, meta, text = r.read()
            text = base64.b64decode(text["data"])
            saveFile(filename, text, "wb")
        else:
            saveFile(filename, res["content"], "wb")

        common.log("Done")
    else:
        common.log("Failure")
	def getSchedule(self):
		html = common.fetchPage({'link': self.__urlSchedule})
		container = common.parseDOM(html.get("content"),name='div',attrs={'class': 'b-select-box.*?'})
		list_container = common.parseDOM(container,name='select',attrs={'class': 'select-box-list.*?'})
		items = common.parseDOM(list_container,name='option',attrs={'class': 'select-box-item.*?'})
		data_items = common.parseDOM(list_container,name='option',attrs={'class': 'select-box-item.*?'},ret="data-custom-properties")
		i = 0
		for item in items:
			title = common.replaceHTMLCodes(item).encode('UTF-8')
			link = common.replaceHTMLCodes(data_items[i]).encode('UTF-8')
			link = "%s%s" % (self.__urlBase,link)

			parameters = {"link" : link, "mode" : "getScheduleDetail"}
			url = sys.argv[0] + '?' + urllib.parse.urlencode(parameters)
			self.html2ListItem(title,"","","","","","",url,None,True, False);
			i = i+1
	def buildLivestream(self,title,link,time,restart,channel,banner,online):
		html = common.fetchPage({'link': link})
		container = common.parseDOM(html.get("content"),name='div',attrs={'class': "player_viewport.*?"})
		if len(container):
			data = common.parseDOM(container[0],name='div',attrs={},ret="data-jsb")

			if online:
				state = (self.translation(30019)).encode("utf-8")
			else:
				state = (self.translation(30020)).encode("utf-8")
			
			if time:
				time_str = " (%s)" % time
			else:
				time_str = ""
			
			try:
				xbmcaddon.Addon('inputstream.adaptive')
				inputstreamAdaptive = True
			except RuntimeError:
				inputstreamAdaptive = False
			
			if channel:
				channel = "[%s]" % channel
			else:
				channel = "LIVE"

			
			uhd_streaming_url = self.getLivestreamUrl(data,'uhdbrowser')
			if uhd_streaming_url:
				debugLog("Adding UHD Livestream","Info")
				uhdContextMenuItems = []
				if inputstreamAdaptive and restart and online:
					uhdContextMenuItems.append(('Restart', 'RunPlugin(plugin://%s/?mode=liveStreamRestart&link=%s)' % (xbmcaddon.Addon().getAddonInfo('id'), link)))
					uhd_final_title = "[Restart]%s[UHD] - %s%s" % (channel,title,time_str)
				else:
					uhd_final_title = "%s[UHD] - %s%s" % (channel,title,time_str)
				self.html2ListItem(uhd_final_title ,banner,"",state,time,channel,channel, generateAddonVideoUrl(uhd_streaming_url),None,False, True, uhdContextMenuItems)
							
			streaming_url = self.getLivestreamUrl(data,self.videoQuality)
			contextMenuItems = []
			if inputstreamAdaptive and restart and online:
				contextMenuItems.append(('Restart', 'RunPlugin(plugin://%s/?mode=liveStreamRestart&link=%s)' % (xbmcaddon.Addon().getAddonInfo('id'), link)))
				final_title = "[Restart]%s - %s%s" % (channel,title,time_str)
			else:
				final_title = "%s - %s%s" % (channel,title,time_str)
			self.html2ListItem(final_title,banner,"",state,time,channel,channel, generateAddonVideoUrl(streaming_url),None,False, True,contextMenuItems)
Example #47
0
    def getLinks(self, url, banner, playlist):
        playlist.clear()
        url = str(urllib.unquote(url))
        if banner != None:
            banner = urllib.unquote(banner)

        html = common.fetchPage({'link': url})
        data = common.parseDOM(html.get("content"),
                               name='div',
                               attrs={'class': "jsb_ jsb_VideoPlaylist"},
                               ret='data-jsb')

        data = data[0]
        data = common.replaceHTMLCodes(data)
        data = json.loads(data)

        video_items = data.get("playlist")["videos"]

        try:
            current_title_prefix = data.get("selected_video")["title_prefix"]
            current_title = data.get("selected_video")["title"]
            current_desc = data.get("selected_video")["description"].encode(
                'UTF-8')
            current_duration = data.get("selected_video")["duration"]
            current_preview_img = data.get(
                "selected_video")["preview_image_url"]
            if self.useSubtitles:
                if "subtitles" in data.get("selected_video"):
                    current_subtitles = []
                    for sub in data.get("selected_video")["subtitles"]:
                        current_subtitles.append(sub.get(u'src'))
                else:
                    current_subtitles = None
            else:
                current_subtitles = None
            current_id = data.get("selected_video")["id"]
            current_videourl = self.getVideoUrl(
                data.get("selected_video")["sources"])
        except Exception, e:
            current_subtitles = None
            print e
Example #48
0
    def getArchiv(self):
        html = common.fetchPage({'link': self.__urlArchive})
        html_content = html.get("content")

        content = common.parseDOM(html_content,
                                  name='section',
                                  attrs={'class': 'mod_archive_items.*?'})
        archives = common.parseDOM(content,
                                   name='article',
                                   attrs={'class': 'item'})

        for archive in archives:
            title = common.parseDOM(archive,
                                    name='h4',
                                    attrs={'class': 'item_title'})
            if title[0]:
                title = common.replaceHTMLCodes(title[0]).encode('UTF-8')

                link = common.parseDOM(archive, name='a', attrs={}, ret="href")
                link = common.replaceHTMLCodes(link[0]).encode('UTF-8')

                image = common.parseDOM(archive, name='img', ret="src")
                image = common.replaceHTMLCodes(image[0]).replace(
                    "width=395",
                    "width=500").replace("height=209.07070707071",
                                         "height=265").encode('UTF-8')

                description = common.parseDOM(
                    archive, name='div', attrs={'class': 'item_description'})
                description = common.replaceHTMLCodes(
                    description[0]).encode('UTF-8')

                parameters = {
                    "link": link,
                    "title": title,
                    "banner": image,
                    "mode": "getArchiveDetail"
                }
                url = sys.argv[0] + '?' + urllib.urlencode(parameters)
                self.html2ListItem(title, image, "", description, "", "", "",
                                   url, None, True, False)
Example #49
0
    def liveStreamRestart(self, link):
        try:
            xbmcaddon.Addon('inputstream.adaptive')
        except RuntimeError:
            return

        livestream_id = link.rpartition('/')[-1]
        html = common.fetchPage({'link': link})
        bitmovinStreamId = self.getLivestreamBitmovinID(html)
        stream_info = self.getLivestreamInformation(html)

        if bitmovinStreamId:

            title = stream_info['title']
            image = stream_info['image']
            description = stream_info['description']
            duration = stream_info['duration']
            date = stream_info['date']
            channel = stream_info['channel']

            ApiKey = '2e9f11608ede41f1826488f1e23c4a8d'
            response = urllib2.urlopen(
                'http://restarttv-delivery.bitmovin.com/livestreams/%s/sections/?state=active&X-Api-Key=%s'
                % (bitmovinStreamId, ApiKey))  # nosec
            section = json.loads(response.read())[0]

            streamingURL = 'http://restarttv-delivery.bitmovin.com/livestreams/%s/sections/%s/manifests/hls/?startTime=%s&X-Api-Key=%s' % (
                bitmovinStreamId, section.get('id'),
                section.get('metaData').get('timestamp'), ApiKey)

            listItem = createListItem(title, image, description, duration,
                                      date, channel, streamingURL, True, False,
                                      self.defaultbackdrop, self.pluginhandle)
            listItem.setProperty('inputstreamaddon', 'inputstream.adaptive')
            listItem.setProperty('inputstream.adaptive.manifest_type', 'hls')
            self.xbmc.Player().play(streamingURL, listItem)
Example #50
0
    def getLinks(self, url, banner, playlist):
        playlist.clear()
        url = str(urllib.unquote(url))
        debugLog("Loading Videos from %s" % url, 'Info')
        if banner != None:
            banner = urllib.unquote(banner)

        html = common.fetchPage({'link': url})
        data = common.parseDOM(html.get("content"),
                               name='div',
                               attrs={'class': "jsb_ jsb_VideoPlaylist"},
                               ret='data-jsb')
        if len(data):
            try:
                data = data[0]
                data = common.replaceHTMLCodes(data)
                data = json.loads(data)

                video_items = data.get("playlist")["videos"]
                current_title = data.get("selected_video")["title"]
                if data.get("selected_video")["description"]:
                    current_desc = data.get(
                        "selected_video")["description"].encode('UTF-8')
                else:
                    current_desc = ""

                if data.get("selected_video")["duration"]:
                    current_duration = float(
                        data.get("selected_video")["duration"])
                    current_duration = int(current_duration / 1000)
                else:
                    current_duration = 0

                current_preview_img = data.get(
                    "selected_video")["preview_image_url"]
                if "subtitles" in data.get("selected_video"):
                    current_subtitles = []
                    for sub in data.get("selected_video")["subtitles"]:
                        current_subtitles.append(sub.get(u'src'))
                else:
                    current_subtitles = None
                current_videourl = self.getVideoUrl(
                    data.get("selected_video")["sources"])
            except Exception as e:
                debugLog("Error Loading Episode from %s" % url, 'Exception')
                notifyUser((self.translation(30052)).encode("utf-8"))
                current_subtitles = None
                current_videourl = None

            if len(video_items) > 1:
                debugLog(
                    "Found Video Playlist with %d Items" % len(video_items),
                    'Info')
                parameters = {"mode": "playlist"}
                u = sys.argv[0] + '?' + urllib.urlencode(parameters)
                liz = self.html2ListItem(
                    "[ " + (self.translation(30015)).encode("utf-8") + " ]",
                    banner, "", (self.translation(30015)).encode("utf-8"), '',
                    '', '', u, None, True, True)
                for video_item in video_items:
                    try:
                        title = video_item["title"].encode('UTF-8')
                        if video_item["description"]:
                            desc = video_item["description"].encode('UTF-8')
                        else:
                            debugLog("No Video Description for %s" % title,
                                     'Info')
                            desc = ""

                        if video_item["duration"]:
                            duration = float(video_item["duration"])
                            duration = int(duration / 1000)
                        else:
                            duration = 0

                        preview_img = video_item["preview_image_url"]
                        sources = video_item["sources"]
                        if "subtitles" in video_item:
                            debugLog("Found Subtitles for %s" % title, 'Info')
                            subtitles = []
                            for sub in video_item["subtitles"]:
                                subtitles.append(sub.get(u'src'))
                        else:
                            subtitles = None
                        videourl = self.getVideoUrl(sources)

                        liz = self.html2ListItem(title, preview_img, "", desc,
                                                 duration, '', '', videourl,
                                                 subtitles, False, True)
                        playlist.add(videourl, liz)
                    except Exception as e:
                        debugLog(e, 'Error')
                        continue
                return playlist
            else:
                debugLog(
                    "No Playlist Items found for %s. Setting up single video view."
                    % current_title.encode('UTF-8'), 'Info')
                liz = self.html2ListItem(current_title, current_preview_img,
                                         "", current_desc, current_duration,
                                         '', '', current_videourl,
                                         current_subtitles, False, True)
                playlist.add(current_videourl, liz)
                return playlist
        else:
            notifyUser((self.translation(30052)).encode("utf-8"))
            sys.exit()
def megaDownload(file, dest_path, dest_filename):
    file = file[1]
    file_handle = None
    file_key = None
    is_public = False

    file_data = mega_instance._api_request({'a': 'g', 'g': 1, 'n': file['h']})
    k = file['k']
    iv = file['iv']
    meta_mac = file['meta_mac']

    # Seems to happens sometime... When  this occurs, files are
    # inaccessible also in the official also in the official web app.
    # Strangely, files can come back later.
    if 'g' not in file_data:
        raise mega.RequestError('File not accessible anymore')
    file_url = file_data['g']
    file_size = file_data['s']
    attribs = mega.base64_url_decode(file_data['at'])
    attribs = mega.decrypt_attr(attribs, k)

    if dest_filename is not None:
        file_name = dest_filename
    else:
        file_name = attribs['n']

    ret = common.fetchPage({"link": file_url, "progress": True})
    input_file = ret["content"]
    if dest_path is None:
        dest_path = ''
    else:
        dest_path += '/'

    temp_output_file = mega.tempfile.NamedTemporaryFile(mode='w+b',
                                                        prefix='megapy_',
                                                        delete=False)

    k_str = mega.a32_to_str(k)
    counter = mega.Counter.new(128,
                               initial_value=((iv[0] << 32) + iv[1]) << 64)
    aes = mega.AES.new(k_str, mega.AES.MODE_CTR, counter=counter)

    mac_str = '\0' * 16
    mac_encryptor = mega.AES.new(k_str, mega.AES.MODE_CBC, mac_str)
    iv_str = mega.a32_to_str([iv[0], iv[1], iv[0], iv[1]])

    for chunk_start, chunk_size in mega.get_chunks(file_size):
        #chunk = input_file.read(chunk_size)
        chunk = input_file[:chunk_size]
        input_file = input_file[chunk_size:]

        chunk = aes.decrypt(chunk)
        temp_output_file.write(chunk)

        encryptor = mega.AES.new(k_str, mega.AES.MODE_CBC, iv_str)
        for i in range(0, len(chunk) - 16, 16):
            block = chunk[i:i + 16]
            encryptor.encrypt(block)

        #fix for files under 16 bytes failing
        if file_size > 16:
            i += 16
        else:
            i = 0

        block = chunk[i:i + 16]
        if len(block) % 16:
            block += '\0' * (16 - (len(block) % 16))
        mac_str = mac_encryptor.encrypt(encryptor.encrypt(block))

    file_mac = mega.str_to_a32(mac_str)

    temp_output_file.close()

    # check mac integrity
    if (file_mac[0] ^ file_mac[1], file_mac[2] ^ file_mac[3]) != meta_mac:
        raise ValueError('Mismatched mac')

    mega.shutil.move(temp_output_file.name, dest_path + file_name)
Example #52
0
    def getLiveStreams(self):
        liveurls = {}

        try:
            xbmcaddon.Addon('inputstream.adaptive')
            inputstreamAdaptive = True
        except RuntimeError:
            inputstreamAdaptive = False

        liveurls[
            'ORF1'] = "http://apasfiisl.apa.at/ipad/orf1_" + self.videoQuality.lower(
            ) + "/orf.sdp/playlist.m3u8|User-Agent=Mozilla"
        liveurls[
            'ORF2'] = "http://apasfiisl.apa.at/ipad/orf2_" + self.videoQuality.lower(
            ) + "/orf.sdp/playlist.m3u8|User-Agent=Mozilla"
        liveurls[
            'ORF3'] = "http://apasfiisl.apa.at/ipad/orf3_" + self.videoQuality.lower(
            ) + "/orf.sdp/playlist.m3u8|User-Agent=Mozilla"
        liveurls[
            'ORFS'] = "http://apasfiisl.apa.at/ipad/orfs_" + self.videoQuality.lower(
            ) + "/orf.sdp/playlist.m3u8|User-Agent=Mozilla"

        channelnames = {}
        channelnames['ORF1'] = "ORF 1"
        channelnames['ORF2'] = "ORF 2"
        channelnames['ORF3'] = "ORF III"
        channelnames['ORFS'] = "ORF Sport+"

        html = common.fetchPage({'link': self.__urlLive})
        wrapper = common.parseDOM(html.get("content"),
                                  name='div',
                                  attrs={'class': 'base_list_wrapper mod_epg'})
        items = common.parseDOM(wrapper[0],
                                name='li',
                                attrs={'class': 'base_list_item.program.*?'})
        items_class = common.parseDOM(
            wrapper[0],
            name='li',
            attrs={'class': 'base_list_item.program.*?'},
            ret="class")
        i = 0
        for item in items:
            program = items_class[i].split(" ")[2].encode('UTF-8').upper()
            i += 1
            if channelnames[program]:
                banner = common.parseDOM(item, name='img', ret="src")
                banner = common.replaceHTMLCodes(banner[0]).encode('UTF-8')

                title = common.parseDOM(item, name='h4')
                title = common.replaceHTMLCodes(title[0]).encode('UTF-8')

                time_str = common.parseDOM(item,
                                           name='span',
                                           attrs={'class': 'meta.meta_time'})
                time_str = common.replaceHTMLCodes(
                    time_str[0]).encode('UTF-8').replace("Uhr", "").replace(
                        ".", ":").strip()

                if self.getBroadcastState(time_str):
                    state = (self.translation(30019)).encode("utf-8")
                else:
                    state = (self.translation(30020)).encode("utf-8")

                initial = True
                link = liveurls[program]
                final_title = "[%s] - %s (%s)" % (channelnames[program], title,
                                                  time_str)

                child_list = common.parseDOM(item,
                                             name='li',
                                             attrs={'class': 'base_list_item'})
                for child_list_item in child_list:
                    contextMenuItems = []
                    child_restart = common.parseDOM(
                        child_list_item,
                        name='span',
                        attrs={'class': 'is_restartable.*?'},
                        ret="class")

                    child_list_title = common.parseDOM(child_list_item,
                                                       name='h4')
                    child_list_title = common.replaceHTMLCodes(
                        child_list_title[0]).encode('UTF-8')
                    child_list_link = common.parseDOM(
                        child_list_item,
                        name='a',
                        attrs={'class': 'base_list_item_inner'},
                        ret="href")
                    child_list_link = common.replaceHTMLCodes(
                        child_list_link[0])
                    child_list_time = common.parseDOM(
                        child_list_item,
                        name='span',
                        attrs={'class': 'meta.meta_time'})
                    child_list_time = common.replaceHTMLCodes(
                        child_list_time[0]).encode('UTF-8').replace(
                            "Uhr", "").replace(".", ":").strip()

                    if initial:
                        if inputstreamAdaptive and child_restart:
                            final_title = "[Restart][%s] - %s (%s)" % (
                                channelnames[program], title, time_str)
                            contextMenuItems.append((
                                'Restart',
                                'RunPlugin(plugin://%s/?mode=liveStreamRestart&link=%s)'
                                % (xbmcaddon.Addon().getAddonInfo('id'),
                                   child_list_link)))

                        self.html2ListItem(final_title, banner, "", state,
                                           time_str, program, program, link,
                                           None, False, True, contextMenuItems)
                        initial = False

                    if child_list_time == time_str and child_list_title != title:
                        if inputstreamAdaptive and child_restart:
                            contextMenuItems.append((
                                'Restart',
                                'RunPlugin(plugin://%s/?mode=liveStreamRestart&link=%s)'
                                % (xbmcaddon.Addon().getAddonInfo('id'),
                                   child_list_link)))
                        child_list_streaming_url = self.getLivestreamUrl(
                            child_list_link,
                            self.videoQuality) + '|User-Agent=Mozilla'
                        child_list_final_title = "[%s] - %s (%s)" % (
                            channelnames[program], child_list_title,
                            child_list_time)

                        self.html2ListItem(child_list_final_title, banner, "",
                                           state, time, program, program,
                                           child_list_streaming_url, None,
                                           False, True, contextMenuItems)
Example #53
0
    def getLiveStreams(self):
        liveurls = {}
        #liveurls['ORF1'] = getm3ucontent("http://apasfiisl.apa.at/ipad/orf1_"+self.videoQuality.lower()+"/orf.sdp/playlist.m3u8")
        #liveurls['ORF2'] = getm3ucontent("http://apasfiisl.apa.at/ipad/orf2_"+self.videoQuality.lower()+"/orf.sdp/playlist.m3u8");
        #liveurls['ORF3'] = getm3ucontent("http://apasfiisl.apa.at/ipad/orf3_"+self.videoQuality.lower()+"/orf.sdp/playlist.m3u8");
        #liveurls['ORFS'] = getm3ucontent("http://apasfiisl.apa.at/ipad/orfs_"+self.videoQuality.lower()+"/orf.sdp/playlist.m3u8");
        liveurls[
            'ORF1'] = "http://apasfiisl.apa.at/ipad/orf1_" + self.videoQuality.lower(
            ) + "/orf.sdp?wowzasessionid=1"
        liveurls[
            'ORF2'] = "http://apasfiisl.apa.at/ipad/orf2_" + self.videoQuality.lower(
            ) + "/orf.sdp?wowzasessionid=1"
        liveurls[
            'ORF3'] = "http://apasfiisl.apa.at/ipad/orf3_" + self.videoQuality.lower(
            ) + "/orf.sdp?wowzasessionid=1"
        liveurls[
            'ORFS'] = "http://apasfiisl.apa.at/ipad/orfs_" + self.videoQuality.lower(
            ) + "/orf.sdp?wowzasessionid=1"

        html = common.fetchPage({'link': self.live_url})
        wrapper = common.parseDOM(
            html.get("content"),
            name='div',
            attrs={'class': 'base_list_wrapper.*mod_epg'})
        items = common.parseDOM(wrapper[0],
                                name='li',
                                attrs={'class': 'base_list_item.program.*?'})
        items_class = common.parseDOM(
            wrapper[0],
            name='li',
            attrs={'class': 'base_list_item.program.*?'},
            ret="class")
        i = 0
        for item in items:
            program = items_class[i].split(" ")[2].encode('UTF-8').upper()
            i += 1

            banner = common.parseDOM(item, name='img', ret="src")
            banner = common.replaceHTMLCodes(banner[0]).encode('UTF-8')

            title = common.parseDOM(item, name='h4')
            title = common.replaceHTMLCodes(title[0]).encode('UTF-8')

            time = common.parseDOM(item,
                                   name='span',
                                   attrs={'class': 'meta.meta_time'})
            time = common.replaceHTMLCodes(time[0]).encode('UTF-8').replace(
                "Uhr", "").replace(".", ":").strip()

            if self.getBroadcastState(time):
                state = (self.translation(30019)).encode("utf-8")
                state_short = "Online"
            else:
                state = (self.translation(30020)).encode("utf-8")
                state_short = "Offline"

            link = liveurls[program]

            title = "[%s] - %s (%s)" % (program, title, time)
            liz = self.html2ListItem(title, banner, "", state, time, program,
                                     program, link, None, False, 'true')
Example #54
0
    def getCategoriesDetail(self, category, banner):
        url = urllib.unquote(category)
        banner = urllib.unquote(banner)
        html = common.fetchPage({'link': url})

        try:
            show = common.parseDOM(html.get("content"),
                                   name='h3',
                                   attrs={'class': 'video_headline'})
            showname = common.replaceHTMLCodes(show[0]).encode("utf-8")
        except:
            showname = ""
        playerHeader = common.parseDOM(html.get("content"),
                                       name='header',
                                       attrs={'class': 'player_header'})
        bcast_info = common.parseDOM(playerHeader,
                                     name='div',
                                     attrs={'class': 'broadcast_information'})

        try:
            current_duration = common.parseDOM(
                bcast_info, name='span', attrs={'class': 'meta.meta_duration'})

            current_date = common.parseDOM(bcast_info,
                                           name='span',
                                           attrs={'class': 'meta meta_date'})
            if len(current_date) > 0:
                current_date = current_date[0].encode("utf-8")
            else:
                current_date = ""

            current_time = common.parseDOM(bcast_info,
                                           name='span',
                                           attrs={'class': 'meta meta_time'})
            current_link = url
            if len(showname) > 0:
                current_title = "%s - %s" % (showname, current_date)
                try:
                    current_desc = '%s %s - %s\n%s: %s' % (
                        self.translation(30009), current_date, current_time[0],
                        self.translation(30011), current_duration[0])
                except:
                    current_desc = None
                parameters = {
                    "link": current_link,
                    "title": current_title,
                    "banner": banner,
                    "mode": "openSeries"
                }
                url = sys.argv[0] + '?' + urllib.urlencode(parameters)
                self.html2ListItem(current_title, banner, "", current_desc, "",
                                   "", "", url, None, True, False)
            else:
                self.html2ListItem((self.translation(30014)).encode('UTF-8'),
                                   self.defaultbanner, "", "", "", "", "", "",
                                   None, True, False)
        except:
            self.html2ListItem((self.translation(30014)).encode('UTF-8'),
                               self.defaultbanner, "", "", "", "", "", "",
                               None, True, False)

        itemwrapper = common.parseDOM(
            html.get("content"),
            name='div',
            attrs={'class': 'base_list_wrapper.mod_latest_episodes'})
        if len(itemwrapper) > 0:
            items = common.parseDOM(itemwrapper,
                                    name='li',
                                    attrs={'class': 'base_list_item'})
            i = 0
            for item in items:
                i = i + 1
                duration = common.parseDOM(
                    item, name='span', attrs={'class': 'meta.meta_duration'})
                date = common.parseDOM(item,
                                       name='span',
                                       attrs={'class': 'meta.meta_date'})
                date = date[0].encode("utf-8")
                time = common.parseDOM(item,
                                       name='span',
                                       attrs={'class': 'meta.meta_time'})
                title = common.replaceHTMLCodes(
                    common.parseDOM(item, name='a',
                                    ret="title")[0]).encode("utf-8").replace(
                                        'Sendung ', '')
                title = "%s - %s" % (title, date)
                link = common.parseDOM(item, name='a', ret="href")
                try:
                    desc = '%s %s - %s\n%s: %s' % (
                        self.translation(30009), date, time[0],
                        self.translation(30011), duration[0])
                except:
                    desc = None
                parameters = {
                    "link": link[0],
                    "title": title,
                    "banner": banner,
                    "mode": "openSeries"
                }
                url = sys.argv[0] + '?' + urllib.urlencode(parameters)
                self.html2ListItem(title, banner, "", desc, "", "", "", url,
                                   None, True, False)