Пример #1
0
def add_fullepisodes(episode_tree, season_number = -1):
	try:
		episode_menu = episode_tree.find_all('div', class_ = 'episodeContainer')
		for episode_item in episode_menu:
			episode_name = episode_item.find('div', class_ = 'episodeTitle').a.text
			episode_airdate = common.format_date(episode_item.find('div', class_ = 'episodeAirDate').contents[1].strip(), '%b %d, %Y', '%d.%m.%Y')
			episode_plot = episode_item.find('div', class_ = 'episodeDescription').contents[0].strip()
			episode_thumb = episode_item.find('div', class_ = 'episodeImage').img['src'].split('?')[0]
			url = episode_item.find('div', class_ = 'episodeTitle').a['href']
			try:
				episode_duration = common.format_seconds(episode_item.find('span', class_ = 'episodeDuration').text.replace(')', '').replace('(', ''))
			except:
				episode_duration = -1
			try:
				episode_number = int(episode_item.find('div', class_ = 'episodeIdentifier').text.split('#' + season_number)[1])
			except:
				episode_number = -1
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels = {	'title' : episode_name,
							'durationinseconds' : episode_duration,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate }
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	except:
		pass
Пример #2
0
def webepisodes():
	episode_url = common.args.url
	episode_data = connection.getURL(episode_url)
	web_tree = BeautifulSoup(episode_data, 'html.parser')
	episode_menu = web_tree.find_all('div', class_ = 'view-mode-vid_teaser_show_episode')
	for i, episode_item in enumerate(episode_menu):
		if 'tve-video-auth' not in episode_item['class']:
			episode_name = episode_item['omniture-title']
			try:
				season_number = int(re.compile('Season (\d+)').findall(episode_item.find(class_ = 'caption'))[0])
			except:
				season_number = -1
			try:
				episode_number = int(re.compile('Episode (\d+)').findall(episode_item.find(class_ = 'caption'))[0])
			except:
				episode_number = -1
			try:
				episode_thumb = episode_item.img['src']
			except:
				episode_thumb = None
			url = BASE + episode_item['omniture-id']
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
						 'season' : season_number,
						 'episode' : episode_number,
						}
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	common.set_view('episodes')
Пример #3
0
def add_fullepisodes_southpark(episode_tree):
	try:
		season = urllib.unquote(sys.argv[2].split('&')[2].split('=')[1].replace('%22','')).split(' ')[1]
		episode_menu = episode_tree.find_all('article', class_ = 'thumb')
		for episode_item in episode_menu:
			episode_name = episode_item.find(class_ = 'title')
			if episode_name is None:
				continue
			url = episode_item.a['href']
			try:
				season_number, episode_number = re.compile('s([0-9]{2})e([0-9]{2})').findall(url)[0]
			except:
				episode_number = -1
				season_number = -1
			
			if int(season) != int(season_number):
				continue
			episode_name = episode_name.string.strip()
			episode_plot = episode_item.find('p', class_ = 'episode').string.strip()
			episode_airdate = episode_item.find(class_ = 'air-date').string.strip()
			episode_airdate = common.format_date(episode_airdate , '%m.%d.%Y', '%d.%m.%Y')
			episode_thumb = re.match('(.*?)url\(\'(.*?)\'\)', episode_item.find('a', class_ = 'fill')['style']).group(2)
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate }
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	except:
		pass
Пример #4
0
def episodes(episode_url = common.args.url):
	episode_data = connection.getURL(episode_url)
	episode_menu = simplejson.loads(episode_data)
	for episode_item in episode_menu['items']:
		if episode_item['videos']:
			url = episode_item['guid']
			episode_name = episode_item['title']
			episode_plot = episode_item['description']
			episode_airdate = common.format_date(episode_item['airdate'], '%Y-%m-%d %H:%M:%S', '%d.%m.%Y')
			episode_duration = int(episode_item['videos'].itervalues().next()['length']) / 1000
			try:
				episode_thumb = episode_item['images']['kids-mezzannine-16x9']['url']
			except:
				try:
					episode_thumb = episode_item['images']['kids-mezzannine-4x3']['url']
				except:
					episode_thumb = episode_item['images']['mezzanine']['url']
			HD = False
			for video in episode_item['videos']['flash'].itervalues():
				try:
					if video['bitrate'] > 2000:
						HD = True
				except:
					pass
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'durationinseconds' : episode_duration,
							'plot' : episode_plot,
							'premiered' : episode_airdate }
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, HD = HD, quality_mode = 'select_quailty')
	common.set_view('episodes')
Пример #5
0
def add_fullepisodes(episode_tree, season_number = -1):
	try:
		episode_menu = episode_tree.find_all('div', class_ = 'episode_guide')
		for episode_item in episode_menu:
			episode_name = common.replace_signs(episode_item.find('img')['title'])
			episode_airdate = common.format_date(episode_item.find('p', class_ = 'aired_available').contents[1].strip(), '%m/%d/%Y', '%d.%m.%Y')
			episode_plot = common.replace_signs(episode_item.find('p', class_ = False).text)
			episode_thumb = episode_item.find('img')['src'].split('?')[0]
			url = episode_item.find('div', class_ = 'thumb_image').a['href']
			try:
				episode_number = int(episode_item.find('a', class_ = 'title').contents[1].split('Episode ' + season_number)[1])
			except:
				try:
					episode_number = int(url.split('-0')[1])
				except:
					episode_number = -1
			if season_number == -1:
				season_number = int(url.split('-')[-3])
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels = {	'title' : episode_name,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate }
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	except:
		pass
Пример #6
0
def add_clips_southpark(episode_tree):
	try:
		episode_menu = episode_tree.find_all('li', class_ = 'clips_thumb')
		clip_titles = []
		for episode_item in episode_menu:
			episode_name = episode_item.find('a', class_ = 'clips_thumb_link', text = True).string
			if episode_name not in clip_titles:
				clip_titles.append(episode_name)
				episode_plot = episode_item.find('h6').string.replace('"', '')
				url = episode_item.find('a')['href']
				episode_thumb = episode_item.find('img')['src'].split('?')[0]
				try:
					episode_duration_seconds = common.format_seconds(episode_item.find('span', class_ = 'clips_duration').string)
				except:
					episode_duration_seconds = -1
				try:
					episode_season = int(episode_item.find('h5', class_ = 'clips_thumb_season').string.replace('Season ', ''))
				except:
					episode_season = -1
				u = sys.argv[0]
				u += '?url="' + urllib.quote_plus(url) + '"'
				u += '&mode="' + SITE + '"'
				u += '&sitemode="play_video"'
				infoLabels={	'title' : episode_name,
								'duration' : episode_duration_seconds,
								'season' : episode_season,
								'plot' : episode_plot,
								'tvshowtitle' : 'South Park'}
				common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	except:
		pass
Пример #7
0
def add_clips(episode_tree):
	try:
		episode_menu = episode_tree.find_all('div', class_ = 'block')
		for episode_item in episode_menu:
			episode_name = common.replace_signs(episode_item.find('h3').a.text)
			episode_plot = common.replace_signs(episode_item.find('p', class_ = False).text)
			episode_thumb = episode_item.find('img')['src'].split('?')[0]
			url = episode_item.find('div', class_ = 'thumb_area').a['href']
			try:
				episode_airdate = episode_item.find('div', class_ = 'details').contents[0].split(' ', 1)[1].strip()
				episode_airdate = common.format_date(episode_airdate, '%B %d, %Y', '%d.%m.%Y')
			except:
				episode_airdate = -1
			try:
				episode_duration = common.format_seconds(episode_item.find('h3').small.text.replace(')', '').replace('(', ''))
			except:
				episode_duration = -1
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels = {	'title' : episode_name,
							'durationinseconds' : episode_duration,
							'plot' : episode_plot,
							'premiered' : episode_airdate }
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels)
	except:
		pass
Пример #8
0
def episodes_json(SITE):
    episode_url = common.args.url
    master_name = episode_url.split('#')[0]
    episode_url = episode_url.split('#')[1]
    episode_data = connection.getURL(episode_url)
    episode_menu = simplejson.loads(episode_data)
    for episode_item in episode_menu:
        url = episode_item['episodeID']
        try:
            episode_duration = episode_item['length']
        except:
            episode_duration = -1
        try:
            episode_airdate = common.format_date(episode_item['airDate'].split('on ')[1],'%B %d, %Y')
        except:
            episode_airdate = -1
        try:
            episode_plot = episode_item['summary']
        except:
            episode_plot = episode_item['shortdescription']
        episode_name = episode_item['title']
        if episode_name == master_name:
            video_url = EPISODE % url
            video_data = connection.getURL(video_url)
            video_tree = BeautifulSoup(video_data, 'html.parser')
            episode_name = video_tree.headline.string
        elif episode_name == "":
            episode_name = episode_plot
        try:
            season_number = int(episode_item['identifier'].split(',')[0].split(' ')[1])
        except:
            season_number = -1
        try:
            episode_number =  int(episode_item['identifier'].split(', ')[1].split(' ')[1].replace(' Episode ', ''))
        except:
            try:
                episode_number =  int(episode_item['identifier'].split(', ')[1].split(' ')[1])
            except:
                episode_number = -1
        if episode_number > 100:
            episode_number = int(re.compile('episode-(\d*)').findall(connection.getRedirect(episode_item['shareURL']))[0])
        try:
            episode_thumb = episode_item['640x360_jpg']
        except:
            episode_thumb = None
        u = sys.argv[0]
        u += '?url="' + urllib.quote_plus(url) + '"'
        u += '&mode="' + SITE + '"'
        u += '&sitemode="play_video"'
        infoLabels={    'title' : episode_name,
                        'durationinseconds' : episode_duration,
                        'season' : season_number,
                        'episode' : episode_number,
                        'plot' : episode_plot,
                        'premiered' : episode_airdate }
        common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
    common.set_view('episodes')
Пример #9
0
def add_video(episode_tree, episode = False):
	try:
		episode_menu = episode_tree.find_all(itemtype = 'http://schema.org/TVEpisode')
		if not episode_menu:
			episode_menu = episode_tree.find_all(itemtype = 'http://schema.org/VideoObject')
		for episode_item in episode_menu:
			if episode == False or episode_item.find(class_ = 'episode'):
				episode_name = episode_item.find('meta', itemprop = 'name')['content']
				episode_plot = episode_item.find('meta', itemprop = 'description')['content']
				url = episode_item.find('meta', itemprop = 'url')['content']
				try:
					episode_thumb = episode_item.find('meta', itemprop = 'image')['content'].split('?')[0]
				except:
					try:
						episode_thumb = episode_item.find('meta', itemprop = 'thumbnailUrl')['content'].split('?')[0]
					except:
						episode_thumb = episode_item.find('img')['src'].split('?')[0]
				try:
					episode_airdate = episode_item.find('meta', itemprop = 'uploadDate')['content']
				except:
					try:
						episode_airdate = episode_item.find('meta', itemprop = 'datePublished')['content']
						try:
							episode_airdate = common.format_date(episode_airdate, '%B %d, %Y')
						except:
							episode_airdate = common.format_date(episode_airdate, '%b %d, %Y')
					except:
						episode_airdate = -1
				try:
					episode_duration = episode_item.find('meta', itemprop = 'duration')['content']
					try:
						duration_mins, duration_seconds = re.compile('([0-9]*)M([0-9]*)S').findall(episode_duration)[0]
						episode_duration_seconds = int(duration_mins) * 60 + int(duration_seconds)
					except:
						episode_duration_seconds = int(episode_duration.replace('S', '').replace('T',''))
				except:
					episode_duration_seconds = -1
				try:
					episode_meta = episode_item.find('div', class_ = 'video_meta').text.split('|')[0]
					season_number = int(episode_meta.split('-')[0].replace('Season', '').strip())
					episode_number = int(episode_meta.split('-')[1].replace('Episode', '').strip()[1:])
				except:
					season_number = -1
					episode_number = -1
				u = sys.argv[0]
				u += '?url="' + urllib.quote_plus(url) + '"'
				u += '&mode="' + SITE + '"'
				u += '&sitemode="play_video"'
				infoLabels={	'title' : episode_name,
								'durationinseconds' : episode_duration_seconds,
								'season' : season_number,
								'episode' : episode_number,
								'plot' : episode_plot,
								'premiered' : episode_airdate }
				common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	except:
		pass
Пример #10
0
def episodes(episode_url = common.args.url):
	try:
		season_number = episode_url.split('#')[1]
	except:
		season_number = -1
	episode_url = episode_url.split('#')[0]
	episode_data = connection.getURL(episode_url)
	episode_menu = simplejson.loads(episode_data)['FolderList'][0]['PlaylistList'][0]
	for episode_item in episode_menu['MediaList']:
		if episode_item['Season'] == season_number or season_number == -1:
			''' THX to foreverguest '''
			path_pattern = re.compile('http:\\/\\/.+?\/(.+?)_[a-zA-Z0-9]+')
			pattern_url = episode_item['Thumbnail_Wide']
			path = path_pattern.findall(pattern_url)
			if not path and episode_item['ClosedCaptionFiles']:
				path = path_pattern.findall(episode_item['ClosedCaptionFiles'][0]['Path'])
			if not path:
				continue
			video_url = BASE + path[0] + '_'
			episode_duration = int(episode_item['DurationInSeconds'])
			episode_name = episode_item['Title']
			episode_plot = episode_item['Description']
			try:
				episode_airdate = common.format_date(episode_item['ReleaseDate'], '%m/%d/%Y')
			except:
				episode_airdate = None
			try:
				episode_number = int(episode_item['Episode'])
			except:
				episode_number = -1
			try:
				episode_thumb = episode_item['Thumbnail_854x480']
			except:
				episode_thumb = None
			try:
				episode_caption = episode_item['ClosedCaptionFiles'][0]['Path']
			except:
				episode_caption = ''
			episode_MPAA = episode_item['Rating']
			episode_genre = episode_item['Genre']
			episode_showtitle = episode_item['ParentChannelName']
			video_url = video_url + '#' + episode_caption
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(video_url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'durationinseconds' : episode_duration,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate,
							'MPAA' : episode_MPAA,
							'Genre' : episode_genre,
							'TVShowTitle' : episode_showtitle}
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode = 'list_qualities')
	common.set_view('episodes')
Пример #11
0
def videos(SITE):
	episode_url = common.args.url
	episode_data = connection.getURL(episode_url)
	episode_tree = simplejson.loads(episode_data)
	for episode_item in episode_tree['series']['playlists']:
		show_name = episode_tree['series']['title']
		episode_item = episode_item['playlist']
		if '|' in episode_item['headline']:
			episode_name = episode_item['headline'].split('|')[-1].strip()
		elif '- ' in episode_item['headline']:
			episode_name = episode_item['headline'].split('- ')[-1].strip()
		else:
			try:
				episode_name = episode_item['headline'].split(':')[1].strip()
			except:
				episode_name = episode_item['headline']
		try:
			episode_info = re.compile('[s|S]([0-9]).[e|E]?([0-9]{0,2}).*').findall(episode_item['title'])
			try:
				episode_season, episode_number = episode_info[0]
			except:
				episode_season = episode_info
				episode_number = -1
		except:
			episode_season = -1
			episode_number = -1
		url = episode_item['id']
		try:
			episode_plot = episode_item['subhead']
		except:
			episode_plot = ''
		episode_thumb = episode_item['image']
		try:
			episode_duration = common.format_seconds(episode_item['duration']['timecode'])
		except:
			continue
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play"'
		infoLabels = {	'title' : episode_name,
						'plot' : episode_plot,
						'durationinseconds' : episode_duration,
						'tvshowtitle' : show_name,
						'season' : episode_season,
						'episode' : episode_number }
		try:
			if (episode_item['distributionPolicies'][0]['distributionPolicy']['policyType'] == 'playable'):
				common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode = 'list_qualities')
		except:
			if (episode_item['distributionPolicies'][0]['policyType'] == 'playable'):
				common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode = 'list_qualities')
		else:
			pass
	common.set_view('episodes')
Пример #12
0
def episodes(SITE, quality = True):
	episode_url = common.args.url
	episode_data = connection.getURL(episode_url)
	episode_menu = simplejson.loads(episode_data)['entries']
	for i, episode_item in enumerate(episode_menu):
		default_mediacontent = None
		for mediacontent in episode_item['media$content']:
			if (mediacontent['plfile$isDefault'] == True) and (mediacontent['plfile$format'] == 'MPEG4'):
				default_mediacontent = mediacontent
			elif (mediacontent['plfile$format'] == 'MPEG4'):
				mpeg4_mediacontent = mediacontent
		if default_mediacontent is None:
			default_mediacontent = mpeg4_mediacontent
		url = default_mediacontent['plfile$url']
		episode_duration = int(episode_item['media$content'][0]['plfile$duration'])
		episode_plot = episode_item['description']
		episode_airdate = common.format_date(epoch = episode_item['pubDate']/1000)
		episode_name = episode_item['title']
		try:
			season_number = int(episode_item['pl' + str(i + 1) + '$season'][0])
		except:
			try:
				season_number = int(episode_item['nbcu$seasonNumber'])
			except:
				season_number = -1
		try:
			episode_number = int(episode_item['pl' + str(i + 1) + '$episode'][0])
		except:
			try:
				episode_number = int(episode_item['nbcu$episodeNumber'])
			except:
				episode_number = -1
		try:
			episode_thumb = episode_item['plmedia$defaultThumbnailUrl']
		except:
			episode_thumb = None
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels={	'title' : episode_name,
						'durationinseconds' : episode_duration,
						'season' : season_number,
						'episode' : episode_number,
						'plot' : episode_plot,
						'premiered' : episode_airdate }
		if quality:
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
		else:
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels)
	common.set_view('episodes')
Пример #13
0
def add_videos_thetonightshow(url, type_, page = 1, added_episodes = []):
	this_url = (TONIGHT_SHOW_FEED % url) + '&offset=' + str((page-1) * 10)
	root_data = connection.getURL(this_url)
	data = simplejson.loads(root_data)
	for video in data['content']:
		if video['type'] == type_:
			if type_ == 'episode':
				episode_name = video['name']
				episode_id = video['episodeNumber']
			else:
				episode_name = video['title']
				episode_id = video['id']
			if episode_id in added_episodes:
				continue
			added_episodes.append(episode_id)
			pid = video['videos'][0]['mpxPublicId']
			episode_url = SMIL % pid
			try:
				episode_plot = BeautifulSoup(video['description']['value'], 'html.parser').p.string
			except:
				episode_plot = ''
			try:
				episode_airdate = common.format_date(video['airDate'][:-6],'%Y-%m-%dT%H:%M:%S','%d.%m.%Y')
			except:
				episode_airdate = -1
			try:
				season_number = int(video['season'])
			except:
				season_number = -1
			try:
				episode_number = int(video['episodeNumber'])
			except:
				episode_number = -1
			try:
				episode_thumb = video['images'][0]['bitImageSmall']
			except:
				episode_thumb = None
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(episode_url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate}
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	if page < int(addon.getSetting('maxpages')):
		add_videos_thetonightshow(url, type_, page + 1, added_episodes)
	common.set_view('episodes')
Пример #14
0
def episodes():
	episode_data = connection.getURL(MOVIES)
	episode_list = simplejson.loads(episode_data)
	episode_menu = episode_list['tcm']['titles']
	for episode_item in episode_menu:
		url = episode_item['vod']['contentId']
		try:
			episode_duration = str(int(episode_item['runtimeMinutes'])*60)
		except:
			episode_duration = -1
		episode_year = episode_item['releaseYear']
		try:
			episode_plot = episode_item['description']
		except:
			episode_plot = ""
		episode_name = episode_item['name']
		try:
			episode_genre = episode_item['tvGenres']
		except:
			episode_genre = ''
		try:
			episode_rating = 'Rated: %s' % episode_item['tvRating']
		except:
			isode_rating = ''
		try:
			episode_director = episode_item['tvDirectors']
		except:
			episode_director = ''
		season_number = -1
		episode_number = -1
		try:
			episode_thumb = episode_item['imageProfiles'][1]['url']
		except:
			episode_thumb = None
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels={    'title' : episode_name,
						'durationinseconds' : episode_duration,
						'season' : season_number,
						'episode' : episode_number,
						'plot' : episode_plot,
						'year' : episode_year,
						'genre' : episode_genre, 
						'mpaa'  : episode_rating,
						'director' : episode_director}
		common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	common.set_view('episodes')
Пример #15
0
def episodes(episode_url = common.args.url):
	try:
		shutil.rmtree(os.path.join(ustvpaths.DATAPATH,'thumbs'))
	except:
		pass
	episode_data = connection.getURL(VIDEOLIST % episode_url.split('#')[0])
	episode_menu = simplejson.loads(episode_data)['videos']
	os.mkdir(os.path.join(ustvpaths.DATAPATH,'thumbs'))
	for episode_item in episode_menu:
		if int(episode_item['fullep']) == int(episode_url.split('#')[1]):
			show_name = episode_item['series_name']
			url = episode_item['guid']
			episode_duration = int(episode_item['duration_secs'])
			episode_plot = episode_item['description_long']
			episode_name = episode_item['title']
			season_number = int(episode_item['season'])
			episode_thumb = episode_item['large_thumbnail']
			thumb_file = episode_thumb.split('/')[-1]
			thumb_path = os.path.join(ustvpaths.DATAPATH, 'thumbs', thumb_file)
			thumbcount = 0
			for name in glob.glob(os.path.join(ustvpaths.DBPATH,'textures[0-9]*.db')):
				thumbcount = thumbcount+ database.execute_command('select count(1) from texture where url = ?', [thumb_path,], fetchone = True, dbfile = name)[0]
			if thumbcount == 0:
				thumb_data = connection.getURL(episode_thumb)
				file = open(thumb_path, 'wb')
				file.write(thumb_data)
				file.close()
			try:
				episode_number = int(episode_item['episode'][len(str(season_number)):])
			except:
				episode_number = -1
			try:
				episode_airdate = common.format_date(episode_item['airdate'],'%Y-%b-%d', '%d.%m.%Y')
			except:
				episode_airdate = -1
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'durationinseconds' : episode_duration,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate,
							'tvshowtitle': show_name }
			common.add_video(u, episode_name, thumb_path, infoLabels = infoLabels)
	common.set_view('episodes')
Пример #16
0
def add_fullepisodes_southpark(episode_tree):
    try:
        season = urllib.unquote(
            sys.argv[2].split('&')[2].split('=')[1].replace('%22',
                                                            '')).split(' ')[1]
        episode_menu = episode_tree.find_all('article', class_='thumb')
        for episode_item in episode_menu:
            episode_name = episode_item.find(class_='title')
            if episode_name is None:
                continue
            url = episode_item.a['href']
            try:
                season_number, episode_number = re.compile(
                    's([0-9]{2})e([0-9]{2})').findall(url)[0]
            except:
                episode_number = -1
                season_number = -1

            if int(season) != int(season_number):
                continue
            episode_name = episode_name.string.strip()
            episode_plot = episode_item.find('p',
                                             class_='episode').string.strip()
            episode_airdate = episode_item.find(
                class_='air-date').string.strip()
            episode_airdate = common.format_date(episode_airdate, '%m.%d.%Y',
                                                 '%d.%m.%Y')
            episode_thumb = re.match(
                '(.*?)url\(\'(.*?)\'\)',
                episode_item.find('a', class_='fill')['style']).group(2)
            u = sys.argv[0]
            u += '?url="' + urllib.quote_plus(url) + '"'
            u += '&mode="' + SITE + '"'
            u += '&sitemode="play_video"'
            infoLabels = {
                'title': episode_name,
                'season': season_number,
                'episode': episode_number,
                'plot': episode_plot,
                'premiered': episode_airdate
            }
            common.add_video(u,
                             episode_name,
                             episode_thumb,
                             infoLabels=infoLabels,
                             quality_mode='list_qualities')
    except:
        pass
Пример #17
0
def episodes(episode_url = common.args.url):
	episode_data = connection.getURL(episode_url)
	episode_json = simplejson.loads(episode_data)['result']
	episode_menu = episode_json['data']
	title = episode_json['title']
	for episode_item in episode_menu:
		if episode_item['status'] == 'AVAILABLE' or (addon.getSetting('cbs_use_login') == 'true' and episode_item['status'] == 'PREMIUM'):
			videourl = episode_item['streaming_url']
			if '_hd_' in videourl:
				HD = True
			else:
				HD = False
			url = BASE + episode_item['url']
			episode_duration = int(common.format_seconds(episode_item['duration']))
			episode_airdate = common.format_date(episode_item['airdate'], '%m/%d/%y')
			if len(episode_item['label']) < len(episode_item['title']) and episode_item['label']:
				episode_name = episode_item['label']
			else:
				episode_name = episode_item['title']
			try:
				season_number = int(episode_item['season_number'])
			except:
				season_number = -1
			try:
				episode_number = int(episode_item['episode_number'])
			except:
				episode_number = -1
			try:
				episode_thumb = episode_item['thumb']['large']
			except:
				episode_thumb = None
			episode_plot = episode_item['description']
			if url is not None:
				u = sys.argv[0]
				u += '?url="' + urllib.quote_plus(url) + '"'
				u += '&mode="' + SITE + '"'
				u += '&sitemode="play_video"'
				infoLabels={	'title' : episode_name,
								'durationinseconds' : episode_duration,
								'season' : season_number,
								'episode' : episode_number,
								'plot' : episode_plot,
								'premiered' : episode_airdate }
				common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities', HD = HD)
			else:
				pass
	common.set_view('episodes')
Пример #18
0
def add_videos(episode_tree):
	episode_menu = episode_tree.find_all('li', recursive = False)
	for episode_item in episode_menu:
		show_name = common.args.name
		episode_link = episode_item.h4.a
		episode_name = episode_link.text
		url = BASE + episode_link['href']
		episode_thumb = episode_item.find('img')['src'].split('?')[0]
		episode_plot = episode_item.find('p', class_ = 'description').text
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels = {	'title' : episode_name,
						'plot' : episode_plot,
						'tvshowtitle' : show_name }
		common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
Пример #19
0
def add_clips_southpark(episode_tree):
    try:
        episode_menu = episode_tree.find_all('li', class_='clips_thumb')
        clip_titles = []
        for episode_item in episode_menu:
            episode_name = episode_item.find('a',
                                             class_='clips_thumb_link',
                                             text=True).string
            if episode_name not in clip_titles:
                clip_titles.append(episode_name)
                episode_plot = episode_item.find('h6').string.replace('"', '')
                url = episode_item.find('a')['href']
                episode_thumb = episode_item.find('img')['src'].split('?')[0]
                try:
                    episode_duration_seconds = common.format_seconds(
                        episode_item.find('span',
                                          class_='clips_duration').string)
                except:
                    episode_duration_seconds = -1
                try:
                    episode_season = int(
                        episode_item.find(
                            'h5', class_='clips_thumb_season').string.replace(
                                'Season ', ''))
                except:
                    episode_season = -1
                u = sys.argv[0]
                u += '?url="' + urllib.quote_plus(url) + '"'
                u += '&mode="' + SITE + '"'
                u += '&sitemode="play_video"'
                infoLabels = {
                    'title': episode_name,
                    'duration': episode_duration_seconds,
                    'season': episode_season,
                    'plot': episode_plot,
                    'tvshowtitle': 'South Park'
                }
                common.add_video(u,
                                 episode_name,
                                 episode_thumb,
                                 infoLabels=infoLabels,
                                 quality_mode='list_qualities')
    except:
        pass
Пример #20
0
def add_videos(episode_tree, SITE):
	episode_menu = episode_tree.find_all('div', class_ = 'media-module')
	show_name = episode_tree.find('h1').text
	for episode_item in episode_menu:
		episode_name = episode_item.a['data-title']
		episode_thumb = urllib.unquote_plus(episode_item.a.img['data-src'].split('url=')[1])
		try:
			episode_duration = common.format_seconds(episode_item.find('div', class_='timestamp').text.strip())
		except:
			episode_duration = -1
		url = episode_item.a['href']
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels = {	'title' : episode_name,
						'durationinseconds' : episode_duration,
						'TVShowTitle' : show_name }
		common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode = 'list_qualities')
Пример #21
0
def episodes_web():
	master_name = common.args.url
	webdata = connection.getURL(WEBSHOWS)
	web_tree =  BeautifulSoup(webdata, 'html.parser', parse_only = SoupStrainer('div', id = 'page-shows'))
	show = web_tree.find('h2', text = master_name).parent.parent
	for item in show.findAll('div', class_ = 'item'):
		print item.find('span')
		if item.find('span', contenttypename = "FullEpisode") is not None:
			url = WEBEPISODE % item.span['titleid']
			print item.find(itemprop = 'duration').string.replace(' minutes', '')
			print int(item.find(itemprop = 'duration').string.replace(' minutes', '')) * 60
			try:
				episode_duration = item.find(itemprop = 'duration').string.replace(' minutes', '').strip()# * 60
			except:
				episode_duration = -1
			try:
				episode_plot = HTMLParser.HTMLParser().unescape(item.find(itemprop = 'description').string)
			except:
				episode_plot = ''
			episode_name = item.img['alt']
			try:
				season_number = int(item.find(itemprop = 'seasonNumber').string)
			except:
				season_number = -1
			try:
				episode_number =  int(item.find(itemprop = 'episodeNumber').string)
			except:
				episode_number = -1
			try:
				episode_thumb = item.find(itemprop = 'thumbnail')['data-standard']
			except:
				episode_thumb = None
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'durationinseconds' : episode_duration,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot}
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	common.set_view('episodes')
Пример #22
0
def episodes(episode_url = common.args.url):
	episode_id, type = episode_url.split('#')
	episode_start = 0
	episode_count = 200
	while episode_start < episode_count:
		episode_data = cove.videos.filter(fields = 'associated_images,mediafiles', filter_program = episode_id, order_by = '-airdate', filter_availability_status = 'Available', limit_start = episode_start, filter_type = type)
		episode_menu = episode_data['results']
		episode_count = episode_data['count']
		episode_stop = episode_data['stop']
		del episode_data
		for episode_item in episode_menu:
			infoLabels={}
			if episode_item['mediafiles']:
				url = str(episode_item['tp_media_object_id'])
				episode_name = episode_item['title']
				try:
					season_number = re.compile('Season (\d*)').findall(episode_name)[0]
				except:
					season_number = -1
				try:
					episode_number = re.compile('Episode (\d*)').findall(episode_name)[0]
				except:
					episode_number = -1
				episode_plot = episode_item['long_description']
				episode_airdate = common.format_date(episode_item['airdate'], '%Y-%m-%d %H:%M:%S', '%d.%m.%Y')
				episode_duration = int(episode_item['mediafiles'][0]['length_mseconds'] / 1000)
				episode_thumb = episode_item['associated_images'][0]['url']
				for episode_thumbs in episode_item['associated_images']:
					if episode_thumbs['type']['eeid'] == 'iPad-Large':
						episode_thumb = episode_thumbs['url']
				u = sys.argv[0]
				u += '?url="' + urllib.quote_plus(url) + '"'
				u += '&mode="' + SITE + '"'
				u += '&sitemode="play_video"'
				infoLabels={	'title' : episode_name,
								'episode' : episode_number,
								'season' : season_number,
								'durationinseconds' : episode_duration,
								'plot' : episode_plot,
								'premiered' : episode_airdate }
				common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels)
		episode_start = episode_stop
	common.set_view('episodes')
Пример #23
0
def episodes(episode_url = common.args.url):
	episode_data = connection.getURL(episode_url)
	episode_tree = BeautifulSoup(episode_data, 'html.parser')
	episode_carousel = episode_tree.find_all('div', class_ = 'tab-wrap')
	for episode in episode_carousel:
		if common.args.name == episode.h2.text:
			episode_menu = episode.find_all('li', class_ = 'result-item')
			for episode_item in episode_menu:
				episode_name = episode_item.img['title']
				episode_thumb = episode_item.img['src']
				episode_exp_id = episode_item.a['data-video']
				episode_plot = episode_item.find('p', class_ = 'description').text.strip()
				url = episode_url
				u = sys.argv[0]
				u += '?url="' + urllib.quote_plus(url) + '#' + urllib.quote_plus(episode_exp_id) + '"'
				u += '&mode="' + SITE + '"'
				u += '&sitemode="play_video"'
				infoLabels={	'title' : episode_name,
								'plot' : episode_plot }
				common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels)
	common.set_view('episodes')
Пример #24
0
def episodesClassic(episode_url = common.args.url):
	episode_data = connection.getURL(episode_url)
	episode_html = simplejson.loads(episode_data)['html']
	tree = BeautifulSoup(episode_html, 'html.parser')
	episode_menu = tree.find_all('div', class_ = 'video-content-wrapper')
	for episode_item in episode_menu:
		url = episode_item.find('a')['href']
		episode_duration = episode_item.find('div', class_ = 'video-content-duration').contents[1].replace('(', '').replace(')', '').strip()
		episode_duration = int(common.format_seconds(episode_duration))
		episode_airdate = episode_item.find('div', class_ = 'video-content-air-date').contents[0].split(':')[1].strip()
		episode_airdate = common.format_date(episode_airdate, '%m.%d.%Y')
		show_name = url.split('/')[2]
		episode_name = url.split('/')[-1].replace(show_name.replace('_', '-'), '').replace('-', ' ').title().replace(' T ', '\'t ')
		url = BASE + url
		episode_info = episode_item.find('div', class_ = 'video-content-season-info').text
		try:
			season_number = int(episode_info.split(',')[0].split(' ')[1].strip())
		except:
			season_number = -1
		try:
			episode_number = int(episode_info.split(',')[1].strip().split(' ')[1])
		except:
			episode_number = -1
		try:
			episode_thumb = episode_item.find('img')['src']
		except:
			episode_thumb = None
		episode_plot = episode_item.find('div', class_ = 'video-content-description').string
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels={	'title' : episode_name,
						'durationinseconds' : episode_duration,
						'season' : season_number,
						'episode' : episode_number,
						'plot' : episode_plot,
						'premiered' : episode_airdate }
		common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	common.set_view('episodes')
Пример #25
0
def episodes(episode_url = common.args.url):
	episode_data = connection.getURL(EPISODES + episode_url)
	episode_data2 = simplejson.loads(episode_data)['list_html']
	episode_tree = BeautifulSoup(episode_data2, 'html.parser').find('ul', id = 'videoList_ul')
	if episode_tree:
		episode_menu = episode_tree.find_all('li', recursive = False)
		for episode_item in episode_menu:
			infoLabels={}
			url = episode_item['id'][6:]
			episode_thumb = episode_item.img['src'].replace('103x69', '640x480')
			episode_name = episode_item.span.string
			episode_plot = episode_item.find(id = 'viddesc_' + url).string
			show_name = episode_item.find(id = 'vidtitle_' + url).string
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'plot' : episode_plot,
							'tvshowtitle' : show_name }
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels)
	common.set_view('episodes')
Пример #26
0
def episodes():
	episode_values = {	'video_browser_action' : 'filter',
						'params[type]' : 'all',
						'params[filter]' : common.args.url,
						'params[page]' : '1',
						'params[post_id]' : '71306',      
						'module_id_base' : 'rb-video-browser' }
	episode_data = connection.getURL(VIDEOURL, episode_values)
	episode_tree = simplejson.loads(episode_data)['html']['date']
	episode_menu = BeautifulSoup(episode_tree, 'html.parser').find_all('li')
	for episode_item in episode_menu:
		episode_name = episode_item.a.img['title']
		episode_plot = episode_item.a.img['alt'].replace('/n',' ')
		episode_thumb = episode_item.a.img['src']
		url = episode_item.a['href']		
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels={	'title' : episode_name,
						'plot' : episode_plot }
		common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels)
	common.set_view('episodes')
Пример #27
0
def episodes(episode_url = common.args.url):
	episode_data = connection.getURL(episode_url)
	episode_menu = simplejson.loads(episode_data.replace('}{', '},{'))['results']
	for episode_item in episode_menu:
		episode_airdate = common.format_date(episode_item['airdate'],'%Y-%m-%d', '%d.%m.%Y')
		if (episode_item['authEndDate'] is None or time.time() >= long(episode_item['authEndDate'])/1000) or (common.args.name == 'Clips'):
			show_name = common.args.name
			url = episode_item['videoURL']
			episode_duration = int(episode_item['length'])
			episode_plot = episode_item['shortDescription']
			episode_name = episode_item['name']
			try:
				season_number = episode_item['season']
			except:
				season_number = -1
			try:
				episode_number = episode_item['episode']
			except:
				episode_number = -1
			try:
				episode_thumb = episode_item['videoStillURL']
			except:
				episode_thumb = None
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'durationinseconds' : episode_duration,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate,
							'tvshowtitle': show_name }
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels,  quality_mode  = 'list_qualities')
	common.set_view('episodes')
Пример #28
0
def episodes(episode_url = common.args.url):
	episode_data = connection.getURL(episode_url, header = {'X-Forwarded-For' : '12.13.14.15'})
	episode_menu = simplejson.loads(episode_data)['results']
	for episode_item in episode_menu:
		try:
			show_name = episode_item['seriesTitle']
		except:
			show_name = ''
		try:
			episode_name = episode_item['title'].split(':')[1].replace('"', '')
		except:
			episode_name = episode_item['title']
		url = EPISODE_URL % episode_item['urlKey']
		try:
			episode_plot = episode_item['description']
		except:
			episode_plot = ''
		try:
			image = episode_item['images'][0]['assets'][0]['path']
			episode_thumb = BASE + image
		except:
			episode_thumb = None
		try:
			episode_duration = common.format_seconds(episode_item['duration'])
		except:
			episode_duration = -1
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels = {	'title' : episode_name,
						'plot' : episode_plot,
						'durationinseconds' : episode_duration,
						'tvshowtitle' : show_name }
		common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	common.set_view('episodes')
Пример #29
0
def add_clips(episode_tree, season_number = -1):
	try:
		episode_menu = episode_tree.find_all('div', class_ = 'search_pad')
		for episode_item in episode_menu:
			show_name = episode_item.find('div', class_ = 'search_show').text
			episode_name = episode_item.find('div', class_ = 'search_text').a.text.strip()
			episode_plot = episode_item.find('div', class_ = 'search_text').contents[4].strip()
			url = episode_item.find('div', class_ = 'search_text').a['href']
			episode_thumb = episode_item.find('div', class_ = 'search_image').img['src'].split('?')[0]
			try:
				episode_airdate = episode_item.find('div', class_ = 'episode_meta').contents[5].text.replace('Aired: ', '').strip()
				episode_airdate = common.format_date(episode_airdate, '%B %d, %Y', '%d.%m.%Y')
			except:
				episode_airdate = -1
			try:
				episode_duration = common.format_seconds(episode_item.find('span', class_ = 'search_duration').text.replace(')', '').replace('(', ''))
			except:
				episode_duration = -1
			try:
				episode_number = int(episode_item.find('div', class_ = 'episode_meta').contents[1].text.split('#')[1])
			except:
				episode_number = -1
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels = {	'title' : episode_name,
							'durationinseconds' : episode_duration,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate,
							'tvshowtitle': show_name }
			common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	except:
		pass
Пример #30
0
def episodes(SITE):
    episode_url = common.args.url
    try:
        season_number = int(episode_url.split('filterBySeasonNumber=')[1])
    except:
        season_number = 0 
    episode_data = connection.getURL(episode_url)
    episode_tree = BeautifulSoup(episode_data, 'html.parser')
    episode_menu = episode_tree.find_all('episode')
    for episode_item in episode_menu:
        try:
            episode_season_number = int(episode_item['episeasonnumber'])
        except:
            episode_season_number = 0
        if episode_season_number == season_number or 'filterBySeasonNumber'  not in episode_url:
            segments = episode_item.find_all('segment')
            if len(segments) == 0:
                print episode_item
                try:
                    type = episode_item['episodeType']
                except:
                    type = episode_item['episodetype']
                if type == 'EPI':
                    continue
                else:
                    url = episode_item['id']
            else:
                url = ''
                for segment in segments:
                    url = url + ',' + segment['id']
                url = url[1:]
            try:
                episode_duration = episode_item['duration']
                episode_duration = int(common.format_seconds(episode_duration))
            except:
                episode_duration = 0
                for segment_duration in segments:
                    episode_duration += float(segment_duration['duration'])
            try:
                episode_airdate = common.format_date(episode_item['originalpremieredate'].split(' ')[0],'%m/%d/%Y')
            except:
                try:
                    episode_airdate = common.format_date(episode_item['launchdate'].split(' ')[0],'%m/%d/%Y')
                except:
                    episode_airdate = -1
            episode_name = episode_item['title']
            try:
                season_number = int(episode_item['episeasonnumber'])
            except:
                season_number = -1
            try:
                episode_number = int(episode_item['episodenumber'][:2])
            except:
                episode_number = -1
            try:
                episode_thumb = episode_item['thumbnailurl']
            except:
                episode_thumb = None
            episode_plot = episode_item.description.text
            u = sys.argv[0]
            u += '?url="' + urllib.quote_plus(url) + '"'
            u += '&mode="' + SITE + '"'
            u += '&sitemode="play_video"'
            infoLabels={    'title' : episode_name,
                            'durationinseconds' : episode_duration,
                            'season' : season_number,
                            'episode' : episode_number,
                            'plot' : episode_plot,
                            'premiered' : episode_airdate }
            common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
    common.set_view('episodes')
Пример #31
0
def episodes(episode_url = common.args.url):
	if 'the-tonight-show' in episode_url:
		if 'Clips' in common.args.name:
			add_videos_thetonightshow(episode_url, 'segment')
		else:
			add_videos_thetonightshow(episode_url, 'episode')
		return
	episode_data = connection.getURL(episode_url)
	if 'video_carousel' in episode_url:
		episode_json = simplejson.loads(episode_data)
		episode_menu = episode_json['entries']
		for episode_item in episode_menu:
			if episode_item['restricted'] != 'auth':
				pid = episode_item['mainReleasePid']	
				url = SMIL % pid	
				try:
					episode_duration = int(episode_item['duration'].replace(' min','')) * 60
				except:
					episode_duration = -1
				episode_plot = HTMLParser.HTMLParser().unescape(episode_item['description'])
				epoch = int(episode_item['pubDate']) / 1000
				episode_airdate = common.format_date(epoch = epoch)
				episode_name = HTMLParser.HTMLParser().unescape(episode_item['title'])
				show_title = episode_item['showShortName']
				try:
					season_number = int(episode_item['season'])
				except:
					season_number = -1
				try:
					episode_number = int(episode_item['episode'])
				except:
					episode_number = -1
				try:
					episode_thumb = episode_item['images']['big']
				except:
					episode_thumb = None
				u = sys.argv[0]
				u += '?url="' + urllib.quote_plus(url) + '"'
				u += '&mode="' + SITE + '"'
				u += '&sitemode="play_video"'
				infoLabels={	'title' : episode_name,
								'durationinseconds' : episode_duration,
								'season' : season_number,
								'episode' : episode_number,
								'plot' : episode_plot,
								'premiered' : episode_airdate,
								'TVShowTitle' : show_title}
				common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
	else:
		show_title = re.compile('<h2 class="show-title"><a href=".*?">(.*?)</a></h2>').findall(episode_data)[0]
		episode_menu = re.compile('src="(.*?)".*?<a href="([^"]*?)" class="watch-now-onion-skin">.*?(\d+) min.*?Season (\d+).*?Episode \d+(\d{2}).*?Air date (\d{2}/\d{2}/\d{2}).*?<div class="episode-title dotdotdot"><a href=".*?">(.*?)</a></div>.*?<p>(.*?)</p>', re.DOTALL).findall(episode_data)
		for episode_thumb, episode_url, episode_duration,season_number, episode_number, episode_airdate, episode_name, episode_plot in episode_menu:
			episode_name = HTMLParser.HTMLParser().unescape(episode_name)
			try:
				episode_duration = int(episode_duration) * 60
			except:
				episode_duration = -1
			season_number = int(season_number)
			episode_number =  int(episode_number)
			episode_airdate = common.format_date(episode_airdate,'%m/%d/%y')
			try:
				url = BASE + episode_url
				u = sys.argv[0]
				u += '?url="' + urllib.quote_plus(url) + '"'
				u += '&mode="' + SITE + '"'
				u += '&sitemode="play_video"'
				infoLabels={	'title' : episode_name,
								'durationinseconds' : episode_duration,
								'season' : season_number,
								'episode' : episode_number,
								'plot' : episode_plot,
								'TVShowTitle' : show_title,
								'premiered' : episode_airdate}
				common.add_video(u, episode_name, episode_thumb, infoLabels = infoLabels, quality_mode  = 'list_qualities')
			except:
				pass
	common.set_view('episodes')
Пример #32
0
def add_video_from_manifestfile(manifest_feed):
	""" Add videos based on a manifest feed """
	try:
		shows = []
		items = manifest_feed['result']
		if 'episodes' in items:
			items = items['episodes']
		elif 'videos' in items:
			items = items['videos']
		elif 'playlist' in items:
			items = items['playlist']['videos']
		elif 'episodeVideos' in items:
			items = items['episodeVideos']
		elif 'playlists' in items:
			t_items = []
			k = 0
			for i in items['playlists']:
				l = 0
				for j in items['playlists'][k]['videos']:
					t_items.append(items['playlists'][k]['videos'][l])
					l = l + 1
				k = k + 1
			items = t_items
		for item in items:
			try:
				episode_name = item['title']
			except:
				episode_name = item['shortTitle']
			epoch = float(item['airDate'])
			epoch = common.convert_to_timezone(epoch, '', -5, epoch)  
			episode_airdate = common.format_date(epoch , '', '%d.%m.%Y', epoch)
			episode_plot = item['shortDescription']
			episode_thumb = item['images'][0]['url']
			try:
				episode_duration = item['duration']
			except:
				episode_duration = -1
			url = item['url']
			if not url:
				url = item['canonicalURL']
			try:
				season_number = item['season']['seasonNumber']
				episode_number = str(int(str(item['season']['episodeNumber'])[len(str(season_number)):]))
			except:
				season_number = -1
				episode_number = -1
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'season' : season_number,
							'episode' : episode_number,
							'plot' : episode_plot,
							'premiered' : episode_airdate,
							'durationinseconds' : episode_duration
							}
			show = {'u': u, 'episode_name': episode_name, 'episode_thumb': episode_thumb, 'infoLabels': infoLabels, 'epoch': epoch}
			shows.append(show)
		if len(shows):
			shows = sorted(shows, key=lambda show: show['epoch'], reverse=True)
			for show in shows:
				common.add_video(show['u'], show['episode_name'], show['episode_thumb'], infoLabels = show['infoLabels'], quality_mode  = 'list_qualities')
	except:
		pass