def Episodes(url, page): page = int(page) + 1 DOTCOM, THEPAGE, API = GetLang() headers = { 'Referer': 'http://www.nickjr.%s' % DOTCOM, 'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)' } link = net.http_GET( 'http://www.nickjr.%s/data/property%s.json?&urlKey=%s&apiKey=%s&page=%s' % (DOTCOM, THEPAGE, url, API, page), headers=headers).content link = json.loads(link) data = link['stream'] for k in data: for w in k['items']: try: try: URL = w['data']['id'] except: URL = None try: duration = ' - [' + w['data']['duration'] + ']' except: duration = '' try: name = w['data']['title'] + duration except: try: name = htmlcleaner.cleanUnicode( w['data']['title']) + duration except: try: name = htmlcleaner.clean( w['data']['title']) + duration except: name = '' try: iconimage = w['data']['images']['thumbnail']['r1-1'] except: try: iconimage = w['data']['images']['thumbnail']['r25-12'] except: iconimage = '' try: plot = htmlcleaner.cleanUnicode(w['data']['description']) except: plot = '' if URL: addDir(name, URL, 200, iconimage, plot) except: pass if data: addDir('Next Page >>', url, 1, '', str(page)) setView('movies', 'episode-view')
def PLAY_RTE(name, url, iconimage): name = htmlcleaner.cleanUnicode(name) if 'feeds' in url: link = OPEN_URL(url) URL = re.compile('media:content url="(.+?)"').findall(link)[0] import F4MProxy player = F4MProxy.f4mProxyHelper() player.playF4mLink(URL, name, iconimage) else: if 'f4m' in url: import F4MProxy player = F4MProxy.f4mProxyHelper() player.playF4mLink(url, name, iconimage) else: select = [] returned = [] r = 'http://www.rte.ie/manifests/%s.f4m' % url html = OPEN_URL(r) match = re.compile('href=".+?-(.+?)\.f4m"').findall(html) for i in match: select.append(i + 'P') returned.append(i) link = (returned[xbmcgui.Dialog().select('Please Select', select)]) stream = 'http://cdn.rasset.ie/hls-live/_definst_/%s/%s-%s.m3u8' % ( url, url, link) liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage) liz.setInfo(type='Video', infoLabels={'Title': name}) liz.setProperty("IsPlayable", "true") liz.setPath(stream) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, liz)
def GetTitles(section, page): url_content = net.http_POST(MEDIA_PAGE_REQ_URL, {'showfilm' : showfilm, 'num' : section, 'page' : page, 'number' : itemsperpage, 'apr' : itemsperrow, 'cat_id' : categoryid} ).content items = re.search(r"(?s)<table(.+?)pagecurrent", url_content) if items: items = addon.unescape(items.group(1)) items = unescape(items) for item in re.finditer(r"<a.*?href=\"(.+?)\".*?title=\"(.+?)\".*?<img.*?src=\"(.+?)\"", items): item_url = BASEURL + item.group(1) item_img = item.group(3) item_title = htmlcleaner.cleanUnicode(item.group(2)) try:addon.add_directory({'mode': 'GetLinks', 'url': item_url, 'title': item_title, 'img': item_img, 'type' : typ }, {'title': item_title}, img= item_img) except:pass if re.search(r"(?s)LAST", url_content): addon.add_directory({'mode': 'Browse', 'section' : section, 'page' : str(int(page) + 1), 'type' : typ }, {'title': 'Next Page >>'}) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def TG4_CATCHUP(name): link= OPEN_URL('http://www.tg4.ie/wp-content/themes/tg4-starter/assets/json/tg4data.json')#.encode('utf8') #print link.encode('ascii','ignore') import json data=json.loads(link) uniques=[] for field in data: id= field['id'] iconimage=field['videoStillURL'] description=htmlcleaner.cleanUnicode(field['shortDescription']) name=htmlcleaner.cleanUnicode(field['customFields']['seriestitle']) if name not in uniques: uniques.append(name) addDir(name,'url',12,iconimage,description) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
def TG4_PLAY(name,url): _NAME_ = name link= OPEN_URL('http://www.tg4.ie/wp-content/themes/tg4-starter/assets/json/tg4data.json') data=json.loads(link) uniques=[] for field in data: id= field['id'] iconimage=field['videoStillURL'] description=htmlcleaner.cleanUnicode(field['shortDescription']) name=htmlcleaner.cleanUnicode(field['customFields']['seriestitle']) Name =htmlcleaner.cleanUnicode(field['name']) date=field['customFields']['episode'] if not 'Anois / Now' in date: if name in _NAME_ : addDir(Name,str(id),202,iconimage,description) setView('episodes', '50')
def GetSchedule(channel_id, schedule_utc_date=None, diff=0): import xbmc xbmc.executebuiltin( "ActivateWindow(busydialog)" ) try: import datetime time_format = ADDON.getSetting('timeformat') time_zone_src = ADDON.getSetting('timezonesource') time_zone = get_gmt_offset() if time_zone_src == '0' else int(ADDON.getSetting('timezone')) str_time_format = '%I:%M %p' if time_format == '0' else '%H:%M' current_utc_datetime = get_current_utc_date() if not schedule_utc_date else date_str_to_datetime(schedule_utc_date) ######################################################################### items = get_schedule_for_channel(channel_id, current_utc_datetime, True) ######################################################################### current_tz_datetime = get_current_utc_date() + datetime.timedelta(hours=time_zone) current_sch_tz_datetime = current_utc_datetime + datetime.timedelta(hours=time_zone) current_sch_tz_date = current_sch_tz_datetime.strftime('%Y-%m-%d') current_tz_date = current_tz_datetime.strftime('%Y-%m-%d') current_tz_datetime_minus_diff = current_tz_datetime + datetime.timedelta(hours=(-1*diff)) current_tz_datetime_plus_diff = current_tz_datetime + datetime.timedelta(hours=diff) next = False upcoming = False later = False time_zoned_list = [] recordings = [] import htmlcleaner for item in items: #print item sch = item[1] sch_utc_datetime = (datetime.datetime.utcfromtimestamp(sch['time_start'])) sch_utc_datetime_end = (datetime.datetime.utcfromtimestamp(sch['time_end'])) sch_tz_datetime = sch_utc_datetime + datetime.timedelta(hours=time_zone) sch_tz_datetime_end = sch_utc_datetime_end + datetime.timedelta(hours=time_zone) sch_tz_date = sch_tz_datetime.strftime('%Y-%m-%d') if (diff == 0 and sch_tz_date == current_sch_tz_date) or ( diff != 0 and (sch_tz_datetime<=current_tz_datetime and sch_tz_datetime_end >= current_tz_datetime) or ( sch_tz_datetime >= current_tz_datetime and sch_tz_datetime_end <= current_tz_datetime_plus_diff)): item_text = sch_tz_datetime.strftime(str_time_format) if current_tz_datetime > sch_tz_datetime_end: item_text += ' - [COLOR white][REC][/COLOR]' elif sch_tz_datetime <= current_tz_datetime and current_tz_datetime <= sch_tz_datetime_end and next == False: item_text += ' - [COLOR red][NOW][/COLOR]' next = True elif next == True and upcoming==False: item_text += ' - [COLOR gold][NXT][/COLOR]' next = False upcoming = True elif upcoming == True and later==False: item_text += ' - [COLOR white][LTR][/COLOR]' later = True #print sch['name'] NAME = htmlcleaner.cleanUnicode(sch['name']).encode('utf8') recordings.append( ('', '', NAME,sch['id'],sch['time_start'],sch_tz_date)) time_zoned_list.append( item_text + ' - ' + NAME) xbmc.executebuiltin( "Dialog.Close(busydialog)" ) except: xbmc.executebuiltin( "Dialog.Close(busydialog)" ) raise return time_zoned_list, recordings