Ejemplo n.º 1
0
def prepare_dns_proxy(cj):
    update_url = _addoncompat.get_setting('dns_update_url')
    if update_url:
        try:
            t = os.path.getmtime(IPFILE)
            now = time.time()
            elapsed = now - t
        except:
            elapsed = -1
        try:
            file = open(IPFILE, 'r')
            oldip = file.read()
            file.close()
        except:
            oldip = ''
        if elapsed > DNS_REFESH_DELAY or elapsed == -1:
            myip = getURL(IPURL, connectiontype=0)
            if myip != oldip:
                oldip = myip
                getURL(update_url, connectiontype=0)
        newfile = file = open(IPFILE, 'w')
        file.write(oldip)
        file.close()
    dnsproxy = []
    dnsproxy.append(_addoncompat.get_setting('dns_proxy'))
    dnsproxy.append(_addoncompat.get_setting('dns_proxy_2'))
    MyHTTPHandler._dnsproxy = dnsproxy
    opener = urllib2.build_opener(MyHTTPHandler,
                                  urllib2.HTTPCookieProcessor(cj))
    return opener
Ejemplo n.º 2
0
def getRedirect(url,
                values=None,
                header={},
                connectiontype=_addoncompat.get_setting('connectiontype')):
    try:
        old_opener = urllib2._opener
        cj = cookielib.LWPCookieJar(COOKIE)
        if int(connectiontype) == 1:
            urllib2.install_opener(prepare_dns_proxy(cj))
        elif int(connectiontype) == 2:
            urllib2.install_opener(prepare_us_proxy(cj))
        print '_connection :: getRedirect :: url = ' + url
        if values is None:
            req = urllib2.Request(bytes(url))
        else:
            data = urllib.urlencode(values)
            req = urllib2.Request(bytes(url), data)
        header.update({
            'User-Agent':
            'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0'
        })
        if connectiontype == 2:
            header.update(
                {'X-Forwarded-For': _addoncompat.get_setting('us_proxy')})
        for key, value in header.iteritems():
            req.add_header(key, value)
        response = urllib2.urlopen(req)
        finalurl = response.geturl()
        response.close()
        urllib2.install_opener(old_opener)
    except urllib2.HTTPError, error:
        print 'HTTP Error reason: ', error
        return error.read()
def load_showlist(favored = 0):
	if not os.path.exists(_database.DBFILE):
		_database.create_db()
		refresh_db()
	elif not favored:
		refresh = False
		command = 'select distinct mode from shows order by mode'
		modes = _database.execute_command(command, fetchall = True)
		mode_list = [element[0] for element in modes]
		for network in get_networks():
			if _addoncompat.get_setting(network.SITE) == 'true' and network.SITE not in mode_list:
				refresh = True
		if refresh:
			refresh_db()
	_database.check_db_version()
	command = 'select series_title, mode, submode, url, favor, hide from shows order by series_title'
	shows = _database.execute_command(command, fetchall = True) 
	for series_title, mode, sitemode, url, favor, hide in shows:
		if _addoncompat.get_setting(mode) != 'true':
			continue
		elif hide is 1:
			continue
		elif favored and not favor:
			continue
		add_show(series_title, mode, sitemode, url, favor = favor, hide = hide)	
def getRedirect(url, values = None , header = {}, connectiontype = _addoncompat.get_setting('connectiontype')):
	try:
		old_opener = urllib2._opener
		cj = cookielib.LWPCookieJar(COOKIE)
		if int(connectiontype) == 1:
			urllib2.install_opener(prepare_dns_proxy(cj))
		elif int(connectiontype) == 2:
			urllib2.install_opener(prepare_us_proxy(cj))
		print '_connection :: getRedirect :: url = ' + url
		if values is None:
			req = urllib2.Request(bytes(url))
		else:
			data = urllib.urlencode(values)
			req = urllib2.Request(bytes(url), data)
		header.update({'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0'})
		if connectiontype == 2:
			header.update({'X-Forwarded-For' : _addoncompat.get_setting('us_proxy')})
		for key, value in header.iteritems():
			req.add_header(key, value)
		response = urllib2.urlopen(req)
		finalurl = response.geturl()
		response.close()
		urllib2.install_opener(old_opener)
	except urllib2.HTTPError, error:
		print 'HTTP Error reason: ', error
		return error.read()
Ejemplo n.º 5
0
def load_showlist(favored = 0):
	if not os.path.exists(_database.DBFILE):
		_database.create_db()
		refresh_db()
	elif not favored:
		refresh = False
		command = 'select distinct mode from shows order by mode'
		modes = _database.execute_command(command, fetchall = True)
		mode_list = [element[0] for element in modes]
		for network in get_networks():
			if _addoncompat.get_setting(network.SITE) == 'true' and network.SITE not in mode_list:
				refresh = True
		if refresh:
			refresh_db()
	_database.check_db_version()
	command = 'select series_title, mode, submode, url, favor, hide from shows order by series_title'
	shows = _database.execute_command(command, fetchall = True) 
	for series_title, mode, sitemode, url, favor, hide in shows:
		if _addoncompat.get_setting(mode) == False:
			continue
		elif hide is 1:
			continue
		elif favored and not favor:
			continue
		add_show(series_title, mode, sitemode, url, favor = favor, hide = hide)	
def prepare_dns_proxy(cj):
	update_url = _addoncompat.get_setting('dns_update_url')
	if update_url:
		try:
			t = os.path.getmtime(IPFILE)
			now = time.time()
			elapsed = now - t
		except:
			elapsed = -1
		try:
			file = open(IPFILE, 'r')
			oldip = file.read()
			file.close()
		except:
			oldip = ''
		if elapsed > DNS_REFESH_DELAY or elapsed == -1:
			myip = getURL(IPURL, connectiontype = 0)
			if myip != oldip:
				oldip = myip
				getURL(update_url, connectiontype = 0)
		newfile = file = open(IPFILE, 'w')
		file.write(oldip)
		file.close()
	dnsproxy = []
	dnsproxy.append(_addoncompat.get_setting('dns_proxy'))
	dnsproxy.append(_addoncompat.get_setting('dns_proxy_2'))
	MyHTTPHandler._dnsproxy = dnsproxy
	opener = urllib2.build_opener(MyHTTPHandler, urllib2.HTTPCookieProcessor(cj))
	return opener
Ejemplo n.º 7
0
def play_video(video_url = _common.args.url):
	try:
		qbitrate = _common.args.quality
	except:
		qbitrate = None
	closedcaption = None
	if 'http://' in video_url:
		plot, pid = lookup_meta(video_url)
	else:
		pid = video_url
	video_url = EPISODE % pid
	video_data = _connection.getURL(video_url)
	video_tree = BeautifulSoup(video_data, 'html.parser')
	video_rtmp = video_tree.meta
	playpath_url = None
	if video_rtmp is not None:
		base_url = video_rtmp['base']
		if qbitrate is None:
			video_url2 = video_tree.switch.find_all('video')
			lbitrate = -1
			hbitrate = -1
			sbitrate = int(_addoncompat.get_setting('quality')) * 1024
			for video_index in video_url2:
				bitrate = int(video_index['system-bitrate'])
				if bitrate < lbitrate or lbitrate == -1:
					lbitrate = bitrate
					lplaypath_url = video_index['src']	
				if bitrate > hbitrate and bitrate <= sbitrate:
					hbitrate = bitrate
					playpath_url = video_index['src']	
			if playpath_url is None:
				playpath_url = lplaypath_url
		else:
			bitrate = qbitrate 
			playpath_url = video_tree.switch.find('video', attrs = {'system-bitrate' : qbitrate})['src']
		if '.mp4' in playpath_url:
			playpath_url = 'mp4:' + playpath_url
		else:
			playpath_url = playpath_url.replace('.flv', '')
		try:
			closedcaption = video_tree.find('param', attrs = {'name' : 'ClosedCaptionURL'})['value']
			if closedcaption == '':
				closedcaption = None
		except:
			pass
		if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
				convert_subtitles(closedcaption)
		finalurl = base_url + ' playpath=' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true'
	item = xbmcgui.ListItem( path = finalurl)
	if qbitrate is not None:
		item.setThumbnailImage(_common.args.thumb)
		item.setInfo('Video', {	'title' : _common.args.name,
						'season' : _common.args.season_number,
						'episode' : _common.args.episode_number})
	xbmcplugin.setResolvedUrl(pluginHandle, True, item)
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 8
0
def play_video(video_url=_common.args.url):
    video_url9 = 'stack://'
    sbitrate = int(_addoncompat.get_setting('quality'))
    closedcaption = None
    video_data = _connection.getURL(video_url, forwardheader='12.13.14.15')
    try:
        video_url2 = re.compile(
            '<meta content="http://media.mtvnservices.com/fb/(.+?).swf" property="og:video"/>'
        ).findall(video_data)[0]
    except:
        video_url2 = re.compile("NICK.unlock.uri = '(.+?)';").findall(
            video_data)[0]
    video_url3 = _connection.getRedirect('http://media.mtvnservices.com/fb/' +
                                         video_url2 + '.swf',
                                         referer=BASE)
    video_url4 = urllib.unquote_plus(
        video_url3.split('CONFIG_URL=')[1].split('&')[0]).strip()
    video_data2 = _connection.getURL(
        video_url4,
        referer='http://media.mtvnservices.com/fb/' + video_url2 + '.swf')
    video_tree = BeautifulSoup(video_data2)
    video_url5 = video_tree.feed.string.replace('{uri}', video_url2).replace(
        '&amp;', '&').replace('{type}', 'network')
    video_data3 = _connection.getURL(video_url5)
    video_tree2 = BeautifulSoup(video_data3)
    video_segments = video_tree2.find_all('media:content')
    for video_segment in video_segments:
        hbitrate = -1
        video_url6 = video_segment['url']
        video_data4 = _connection.getURL(video_url6)
        video_menu = BeautifulSoup(video_data4).find_all('rendition')
        for video_index in video_menu:
            bitrate = int(video_index['bitrate'])
            if bitrate > hbitrate and bitrate <= sbitrate:
                hbitrate = bitrate
                video_url7 = video_index.find('src').string
                video_url8 = video_url7 + ' swfurl=' + video_url3.split(
                    '?')[0] + ' pageUrl=' + BASE + ' swfvfy=true'
        video_url9 += video_url8.replace(',', ',,') + ' , '
    finalurl = video_url9[:-3]
    try:
        closedcaption = video_tree2.find_all('media:text')
    except:
        pass
    if (_addoncompat.get_setting('enablesubtitles')
            == 'true') and (closedcaption is not None):
        convert_subtitles(closedcaption)
    xbmcplugin.setResolvedUrl(pluginHandle, True,
                              xbmcgui.ListItem(path=finalurl))
    if (_addoncompat.get_setting('enablesubtitles')
            == 'true') and (closedcaption is not None):
        while not xbmc.Player().isPlaying():
            xbmc.sleep(100)
        for count in range(1, len(closedcaption)):
            xbmc.Player().setSubtitles(
                os.path.join(_common.CACHEPATH,
                             'subtitle-%s.srt' % str(count)))
            while xbmc.Player().isPlaying():
                xbmc.sleep(10)
Ejemplo n.º 9
0
def episodes_from_html(episode_url=_common.args.url, page=1):
    """ Add episodes by analysing the HTML of the page """
    if page == 1:
        episode_data = _connection.getURL(episode_url)
        episode_tree = None
        try:
            episode_url = re.compile("var .*Showcase.* = '(.*)'").findall(
                episode_data)[0]
            if 'http' not in episode_url:
                episode_url = BASE + episode_url
            episode_data = _connection.getURL(episode_url)
        except:
            try:
                episode_tree = BeautifulSoup(episode_data, 'html5lib')
                episode_url = episode_tree.find('div',
                                                class_='content')['data-feed']
                episode_data = _connection.getURL(episode_url)
                episode_tree = BeautifulSoup(episode_data, 'html5lib')
            except:
                pass
    if episode_tree is None:
        episode_tree = BeautifulSoup(episode_data, 'html5lib')
    if 'Clips' in _common.args.name:
        if 'southpark' in episode_url:
            add_clips_southpark(episode_tree)
        else:
            next = episode_tree.find('a', class_=re.compile('next'))
            add_video(episode_tree)
            if next is not None:
                try:
                    if 'href' in next.attrs:
                        nexturl = next['href'].replace(' ', '+')
                    else:
                        nexturl = next['onclick'].split(';')[0].replace(
                            "loadContent('", "").replace("')", "")
                    if 'http' not in nexturl:
                        nexturl = BASE + nexturl
                    if page < int(_addoncompat.get_setting('maxpages')):
                        episodes_from_html(nexturl, page + 1)
                except:
                    pass
    else:
        if 'southpark' in episode_url:
            add_fullepisodes_southpark(episode_tree)
        else:
            next = episode_tree.find('a', class_=re.compile('next'))
            add_video(episode_tree, False)
            if next is not None:
                try:
                    nexturl = next['href']
                    if nexturl[0] == '?':
                        nexturl = episode_url.split('?')[0] + nexturl
                    elif 'http' not in nexturl:
                        nexturl = BASE + nexturl
                    if page < int(_addoncompat.get_setting('maxpages')):
                        episodes_from_html(nexturl, page + 1)
                except:
                    pass
Ejemplo n.º 10
0
def prepare_tor_proxy(cookie_handler):
	if _addoncompat.get_setting('tor_use_local') == 'true':
		tor_proxy = '127.0.0.1'
	else:
		tor_proxy = _addoncompat.get_setting('tor_proxy')
	print 'Using tor proxy at ' + tor_proxy + ':' + _addoncompat.get_setting('tor_socks_port') + ' with exit node: ' + _addoncompat.get_setting('tor_exit_node')
	socks_handler = SocksiPyHandler(socks.PROXY_TYPE_SOCKS5, tor_proxy, int(_addoncompat.get_setting('tor_socks_port')), True)
	opener = urllib2.build_opener(socks_handler, cookie_handler)
	return opener	
Ejemplo n.º 11
0
def play_video(guid = _common.args.url):
	video_url =  VIDEO % guid
	hbitrate = -1
	lbitrate = -1
	sbitrate = int(_addoncompat.get_setting('quality')) * 1024
	closedcaption = None
	video_url2 = None
	finalurl = ''
	video_data = _connection.getURL(video_url)
	video_menu = simplejson.loads(video_data)['items']
	video_item = video_menu[0] 
	try:
		closedcaption = video_item['captions']['sami']['url']
	except:
		pass
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''):
		convert_subtitles(closedcaption.replace(' ', '+'))
	try:
		ipad_url = video_item['videos']['ipad']['url']
		video_data2 = _connection.getURL(ipad_url + '?format=json')
		video_url3 = simplejson.loads(video_data2)['url']
		video_data3 = _connection.getURL(video_url3)
		video_url4 = _m3u8.parse(video_data3)
		uri = None
		for video_index in video_url4.get('playlists'):
			try:
				codecs =  video_index.get('stream_info')['codecs']
			except:
				codecs = ''
			if  codecs != 'mp4a.40.5':
				bitrate = int(video_index.get('stream_info')['bandwidth'])
				if bitrate < lbitrate or lbitrate == -1:
					lbitrate = bitrate
					luri = video_index.get('uri')
				if bitrate > hbitrate and bitrate <= sbitrate:
					hbitrate = bitrate
					uri = video_index.get('uri')
		if uri is None:
			uri = luri
		finalurl = video_url3.rsplit('/', 1)[0] + '/' + uri
	except:
		flash_url = video_item['videos']['flash']['url']
		video_data2 = _connection.getURL(flash_url + '?format=json')
		video_url3 = simplejson.loads(video_data2)['url']
		if '.mp4' in video_url3:
			base_url, playpath_url = video_url3.split('mp4:')
			playpath_url = ' playpath=mp4:' + playpath_url  
		elif 'flv' in video_url3:
			base_url, playpath_url = video_url3.split('flv:')
			playpath_url = ' playpath=' + playpath_url.replace('.flv','')
		finalurl = base_url + playpath_url + '?player= swfurl=' + SWFURL % guid + ' swfvfy=true'
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(_common.SUBTITLESMI)
Ejemplo n.º 12
0
def episodes_from_html(episode_url = _common.args.url, page = 1):
	""" Add episodes by analysing the HTML of the page """
	if page == 1:
		episode_data = _connection.getURL(episode_url)
		episode_tree = None
		try:
			episode_url = re.compile("var .*Showcase.* = '(.*)'").findall(episode_data)[0]
			if 'http' not in episode_url:
				episode_url = BASE + episode_url
			episode_data = _connection.getURL(episode_url)
		except:
			try:
				episode_tree = BeautifulSoup(episode_data, 'html5lib')
				episode_url = episode_tree.find('div', class_ = 'content')['data-feed']
				episode_data = _connection.getURL(episode_url)
				episode_tree = BeautifulSoup(episode_data, 'html5lib')
			except:
				pass
	if episode_tree is  None:
		episode_tree = BeautifulSoup(episode_data, 'html5lib')
	if 'Clips' in _common.args.name  :
		if 'southpark' in episode_url:
			add_clips_southpark(episode_tree)
		else:
			next = episode_tree.find('a', class_ = re.compile('next'))		    
			add_video(episode_tree)
			if next is not None:
				try:
					if 'href' in next.attrs:
						nexturl = next['href'].replace(' ', '+')
					else:
						nexturl = next['onclick'].split(';')[0].replace("loadContent('", "").replace("')", "")
					if 'http' not in nexturl:
						nexturl = BASE + nexturl
					if page < int(_addoncompat.get_setting('maxpages')):
						episodes_from_html(nexturl, page + 1)
				except:
					pass
	else:
		if 'southpark' in episode_url:
			add_fullepisodes_southpark(episode_tree)
		else:
			next = episode_tree.find('a', class_ = re.compile('next'))		    
			add_video(episode_tree, False)
			if next is not None:
				try:
					nexturl = next['href']
					if nexturl[0] == '?': 
						nexturl = episode_url.split('?')[0] + nexturl				
					elif 'http' not in nexturl: 
						nexturl = BASE + nexturl
					if page < int(_addoncompat.get_setting('maxpages')):
						episodes_from_html(nexturl, page + 1)
				except:
					pass
Ejemplo n.º 13
0
def getURL(url, values = None, header = {}, amf = False, savecookie = False, loadcookie = False, connectiontype = _addoncompat.get_setting('connectiontype')):
	try:
		old_opener = urllib2._opener
		cj = cookielib.LWPCookieJar(COOKIE)
		cookie_handler = urllib2.HTTPCookieProcessor(cj)
		if int(connectiontype) == 0:
			urllib2.install_opener(urllib2.build_opener(cookie_handler))
		if int(connectiontype) == 1:
			urllib2.install_opener(prepare_dns_proxy(cookie_handler))
		elif int(connectiontype) == 2:
			urllib2.install_opener(prepare_us_proxy(cookie_handler))
		elif int(connectiontype) == 3:
			handler = TorHandler()
			if ((_addoncompat.get_setting('tor_use_local') == 'true') and _addoncompat.get_setting('tor_as_service') == 'false'):
				if not handler.start_tor():
					print 'Error launching Tor. It may already be running.\n'
			urllib2.install_opener(prepare_tor_proxy(cookie_handler))
		print '_connection :: getURL :: url = ' + url
		if values is None:
			req = urllib2.Request(bytes(url))
		else:
			if amf == False:
				data = urllib.urlencode(values)
			elif amf == True:
				data = values
			req = urllib2.Request(bytes(url), data)
		header.update({'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0'})
		for key, value in header.iteritems():
			req.add_header(key, value)
		if loadcookie is True:
			try:
				cj.load(ignore_discard = True)
				cj.add_cookie_header(req)
			except:
				print 'Cookie Loading Error'
				pass
		response = urllib2.urlopen(req, timeout = TIMEOUT)
		link = response.read()
		if savecookie is True:
			try:
				cj.save(ignore_discard = True)
			except:
				print 'Cookie Saving Error'
				pass	
		response.close()
		if ((int(connectiontype) == 3) and (_addoncompat.get_setting('tor_use_local') == 'true') and (_addoncompat.get_setting('tor_as_service') == 'false')):
			if not handler.kill_tor(): 
				print 'Error killing Tor process! It may still be running.\n' 
			else: 
				print 'Tor instance killed!\n'
		urllib2.install_opener(old_opener)
	except urllib2.HTTPError, error:
		print 'HTTP Error reason: ', error
		return error.read()
Ejemplo n.º 14
0
def set_view(type = 'root'):
	confluence_views = [500,501,50,503,504,508,51]
	if type == 'root':
		xbmcplugin.setContent(pluginHandle, 'movies')
	elif type == 'seasons':
		xbmcplugin.setContent(pluginHandle, 'movies')
	else:
		if type == 'tvshows':
			xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
		xbmcplugin.setContent(pluginHandle, type)
	if _addoncompat.get_setting('viewenable') == 'true':
		view = int(_addoncompat.get_setting(type + 'view'))
		xbmc.executebuiltin('Container.SetViewMode(' + str(confluence_views[view]) + ')')
def prepare_us_proxy():
	us_proxy = 'http://' + _addoncompat.get_setting('us_proxy') + ':' + _addoncompat.get_setting('us_proxy_port')
	proxy_handler = urllib2.ProxyHandler({'http':us_proxy})
	if ((_addoncompat.get_setting('us_proxy_pass') is not '') and (_addoncompat.get_setting('us_proxy_user') is not '')):
		print 'Using authenticated proxy: ' + us_proxy
		password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
		password_mgr.add_password(None, us_proxy, _addoncompat.get_setting('us_proxy_user'), _addoncompat.get_setting('us_proxy_pass'))
		proxy_auth_handler = urllib2.ProxyBasicAuthHandler(password_mgr)
		opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)
	else:
		print 'Using proxy: ' + us_proxy
		opener = urllib2.build_opener(proxy_handler)
	return opener
Ejemplo n.º 16
0
def play_video(video_url = _common.args.url):
	hbitrate = -1
	sbitrate = int(_addoncompat.get_setting('quality')) * 1000
	finalurl = ''
	video_data = _connection.getURL(video_url + '&manifest=m3u')
	video_tree = BeautifulSoup(video_data)
	if (_addoncompat.get_setting('enablesubtitles') == 'true'):
		try:
			closedcaption = video_tree.find('textstream', src = True)['src']
			convert_subtitles(closedcaption)
			video_closedcaption = 'true'
		except:
			video_closedcaption = 'false'
	video_url2 = video_tree.find('video', src = True)['src']
	video_data2 = _connection.getURL(video_url2, savecookie = True)
	video_url3 = _m3u8.parse(video_data2)
	for video_index in video_url3.get('playlists'):
		bitrate = int(video_index.get('stream_info')['bandwidth'])
		if bitrate > hbitrate and bitrate <= sbitrate:
			hbitrate = bitrate
			video_url4 = video_index.get('uri')
	video_data4 = _connection.getURL(video_url4, loadcookie = True)
	key_url = re.compile('URI="(.*?)"').findall(video_data4)[0]
	key_data = _connection.getURL(key_url, loadcookie = True)
	key_file = open(_common.KEYFILE, 'wb')
	key_file.write(key_data)
	key_file.close()
	video_url5 = re.compile('(http:.*?)\n').findall(video_data4)
	for i, video_item in enumerate(video_url5):
		newurl = base64.b64encode(video_item)
		newurl = urllib.quote_plus(newurl)
		video_data4 = video_data4.replace(video_item, 'http://127.0.0.1:12345/foxstation/' + newurl)
	video_data4 = video_data4.replace(key_url, 'http://127.0.0.1:12345/play.key')
	localhttpserver = True
	filestring = 'XBMC.RunScript(' + os.path.join(_common.LIBPATH,'_proxy.py') + ', 12345)'
	xbmc.executebuiltin(filestring)
	time.sleep(2)
	playfile = open(_common.PLAYFILE, 'w')
	playfile.write(video_data4)
	playfile.close()
	finalurl = _common.PLAYFILE
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if ((_addoncompat.get_setting('enablesubtitles') == 'true') and (video_closedcaption != 'false')) or localhttpserver is True:
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (video_closedcaption != 'false'):
		xbmc.Player().setSubtitles(_common.SUBTITLE)
	if localhttpserver is True:
		while xbmc.Player().isPlaying():
			xbmc.sleep(1000)
		_connection.getURL('http://localhost:12345/stop', connectiontype = 0)
Ejemplo n.º 17
0
def set_view(type = 'root'):
	confluence_views = [500,501,502,503,504,508]
	if type == 'root':
		xbmcplugin.setContent(pluginHandle, 'movies')
	elif type == 'seasons':
		xbmcplugin.setContent(pluginHandle, 'movies')
	else:
		if type == 'tvshows':
			xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
		xbmcplugin.setContent(pluginHandle, type)
	viewenable = _addoncompat.get_setting('viewenable')
	if viewenable == 'true':
		view = int(_addoncompat.get_setting(type + 'view'))
		xbmc.executebuiltin('Container.SetViewMode(' + str(confluence_views[view]) + ')')
Ejemplo n.º 18
0
def set_view(type="root"):
    confluence_views = [500, 501, 502, 503, 504, 508]
    if type == "root":
        xbmcplugin.setContent(pluginHandle, "movies")
    elif type == "seasons":
        xbmcplugin.setContent(pluginHandle, "movies")
    else:
        if type == "tvshows":
            xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
        xbmcplugin.setContent(pluginHandle, type)
    viewenable = _addoncompat.get_setting("viewenable")
    if viewenable == "true":
        view = int(_addoncompat.get_setting(type + "view"))
        xbmc.executebuiltin("Container.SetViewMode(" + str(confluence_views[view]) + ")")
Ejemplo n.º 19
0
def episodes(episode_url=_common.args.url):
    episode_data = _connection.getURL(episode_url)
    episode_tree = BeautifulSoup(episode_data)
    if 'Video Clips' in _common.args.name:
        episode_url2 = episode_tree.find('div', class_='v_content')['data-url']
        if episode_tree.find('div', class_='pagination') is not None:
            episode_count = int(
                episode_tree.find('div',
                                  class_='result').text.rsplit(' ',
                                                               1)[1].strip())
            episode_items, episode_rest = divmod(episode_count, 10)
            if episode_rest > 0:
                episode_items = episode_items + 1
            if episode_items > int(_addoncompat.get_setting('maxpages')):
                episode_items = int(_addoncompat.get_setting('maxpages'))
            for episode_item in range(episode_items):
                episode_data2 = _connection.getURL(episode_url2 + '?page=' +
                                                   str(episode_item + 1))
                episode_tree2 = BeautifulSoup(episode_data2)
                add_clips(episode_tree2)
        else:
            episode_data2 = _connection.getURL(episode_url2 + '?page=1')
            episode_tree2 = BeautifulSoup(episode_data2)
            add_clips(episode_tree2)
    else:
        try:
            add_fullepisodes(episode_tree,
                             int(_common.args.name.split(' ')[1]))
        except:
            try:
                add_fullepisodes(episode_tree, int(_common.args.name))
            except:
                add_fullepisodes(episode_tree)
        if episode_tree.find('div', class_='pagination') is not None:
            episode_items2 = episode_tree.find(
                'div', class_='pagination').find_all('a')
            for episode_item2 in episode_items2:
                if (episode_item2.text != 'Next'):
                    episode_data3 = _connection.getURL(episode_item2['href'])
                    episode_tree3 = BeautifulSoup(episode_data3)
                    try:
                        add_fullepisodes(episode_tree3,
                                         int(_common.args.name.split(' ')[1]))
                    except:
                        try:
                            add_fullepisodes(episode_tree3,
                                             int(_common.args.name))
                        except:
                            add_fullepisodes(episode_tree3)
    _common.set_view('episodes')
Ejemplo n.º 20
0
def play_video(video_url=_common.args.url):
    hbitrate = -1
    sbitrate = int(_addoncompat.get_setting('quality')) * 1024
    closedcaption = None
    video_data = _connection.getURL(video_url)
    video_tree = BeautifulSoup(video_data, 'html.parser')
    video_rtmp = video_tree.meta
    if video_rtmp is not None:
        base_url = video_rtmp['base']
        video_url2 = video_tree.switch.find_all('video')
        for video_index in video_url2:
            bitrate = int(video_index['system-bitrate'])
            if bitrate > hbitrate and bitrate <= sbitrate:
                hbitrate = bitrate
                playpath_url = video_index['src']
                if '.mp4' in playpath_url:
                    playpath_url = 'mp4:' + playpath_url
                else:
                    playpath_url = playpath_url.replace('.flv', '')
                finalurl = base_url + ' playpath=' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true'
    else:
        video_data = _connection.getURL(video_url + '&manifest=m3u')
        video_tree = BeautifulSoup(video_data)
        try:
            closedcaption = video_tree.textstream['src']
        except:
            pass
        if (_addoncompat.get_setting('enablesubtitles') == 'true') and (
                closedcaption is not None):
            convert_subtitles(closedcaption)
        video_url2 = video_tree.seq.find_all('video')[0]
        video_url3 = video_url2['src']
        video_url4 = video_url3.split('/')[-1]
        video_data2 = _connection.getURL(video_url3)
        video_url5 = _m3u8.parse(video_data2)
        for video_index in video_url5.get('playlists'):
            bitrate = int(video_index.get('stream_info')['bandwidth'])
            if bitrate > hbitrate and bitrate <= sbitrate:
                hbitrate = bitrate
                finalurl = video_url3.replace(video_url4,
                                              video_index.get('uri'))
    xbmcplugin.setResolvedUrl(pluginHandle, True,
                              xbmcgui.ListItem(path=finalurl))
    if (_addoncompat.get_setting('enablesubtitles') == 'true') and (
            closedcaption is not None):
        while not xbmc.Player().isPlaying():
            xbmc.sleep(100)
        xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 21
0
def play_video(video_url=_common.args.url):
    hbitrate = -1
    sbitrate = int(_addoncompat.get_setting('quality')) * 1024
    closedcaption = None
    video_data = _connection.getURL(video_url)
    video_tree = BeautifulSoup(video_data, 'html.parser')
    video_rtmp = video_tree.meta
    if video_rtmp is not None:
        base_url = video_rtmp['base']
        video_url2 = video_tree.switch.find_all('video')
        for video_index in video_url2:
            bitrate = int(video_index['system-bitrate'])
            if bitrate > hbitrate and bitrate <= sbitrate:
                hbitrate = bitrate
                playpath_url = video_index['src']
                if '.mp4' in playpath_url:
                    playpath_url = 'mp4:' + playpath_url
                else:
                    playpath_url = playpath_url.replace('.flv', '')
                finalurl = base_url + ' playpath=' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true'
    else:
        video_data = _connection.getURL(video_url + '&manifest=m3u')
        video_tree = BeautifulSoup(video_data)
        try:
            closedcaption = video_tree.textstream['src']
        except:
            pass
        if (_addoncompat.get_setting('enablesubtitles')
                == 'true') and (closedcaption is not None):
            convert_subtitles(closedcaption)  #
        video_url2 = video_tree.seq.find_all('video')[0]
        video_url3 = video_url2['src']
        video_url4 = video_url3.split('/')[-1]
        video_data2 = _connection.getURL(video_url3)
        video_url5 = _m3u8.parse(video_data2)
        for video_index in video_url5.get('playlists'):
            bitrate = int(video_index.get('stream_info')['bandwidth'])
            if bitrate > hbitrate and bitrate <= sbitrate:
                hbitrate = bitrate
                finalurl = video_url3.replace(video_url4,
                                              video_index.get('uri'))
    xbmcplugin.setResolvedUrl(pluginHandle, True,
                              xbmcgui.ListItem(path=finalurl))
    if (_addoncompat.get_setting('enablesubtitles')
            == 'true') and (closedcaption is not None):
        while not xbmc.Player().isPlaying():
            xbmc.sleep(100)
        xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 22
0
def play_uri(video_uri = _common.args.url, video_referer = 'www.vh1.com'):
	swfUrl = _connection.getRedirect(BASE2 + video_uri, referer = video_referer)
	configurl = urllib.unquote_plus(swfUrl.split('CONFIG_URL=')[1].split('&')[0])
	configxml = _connection.getURL(configurl)
	video_tree = BeautifulSoup(configxml)
	feed = video_tree.player.feed
	try:
		mrssurl = feed.string.replace('{uri}', video_uri).replace('{ref}', 'None').replace('&amp;', '&').strip()
		mrssxml = _connection.getURL(mrssurl)
		mrsstree = BeautifulSoup(mrssxml)
	except:
		mrsstree = feed
	segmenturls = mrsstree.find_all('media:content')
	stacked_url = 'stack://'
	for segment in segmenturls:
		surl = segment['url']
		videos = _connection.getURL(surl)
		videos = BeautifulSoup(videos).find_all('rendition')
		hbitrate = -1
		sbitrate = int(_addoncompat.get_setting('quality'))
		for video in videos:
			bitrate = int(video['bitrate'])
			if bitrate > hbitrate and bitrate <= sbitrate:
				hbitrate = bitrate
				rtmpdata = video.src.string
				rtmpurl = MP4URL + rtmpdata.split('viacomvh1strm')[2]
		stacked_url += rtmpurl.replace(',',',,') + ' , '
	finalurl = stacked_url[:-3]
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
Ejemplo n.º 23
0
def play_uri(video_uri=_common.args.url, video_referer='www.vh1.com'):
    swfUrl = _connection.getRedirect(BASE2 + video_uri, referer=video_referer)
    configurl = urllib.unquote_plus(
        swfUrl.split('CONFIG_URL=')[1].split('&')[0])
    configxml = _connection.getURL(configurl)
    video_tree = BeautifulSoup(configxml)
    feed = video_tree.player.feed
    try:
        mrssurl = feed.string.replace('{uri}', video_uri).replace(
            '{ref}', 'None').replace('&amp;', '&').strip()
        mrssxml = _connection.getURL(mrssurl)
        mrsstree = BeautifulSoup(mrssxml)
    except:
        mrsstree = feed
    segmenturls = mrsstree.find_all('media:content')
    stacked_url = 'stack://'
    for segment in segmenturls:
        surl = segment['url']
        videos = _connection.getURL(surl)
        videos = BeautifulSoup(videos).find_all('rendition')
        hbitrate = -1
        sbitrate = int(_addoncompat.get_setting('quality'))
        for video in videos:
            bitrate = int(video['bitrate'])
            if bitrate > hbitrate and bitrate <= sbitrate:
                hbitrate = bitrate
                rtmpdata = video.src.string
                rtmpurl = MP4URL + rtmpdata.split('viacomvh1strm')[2]
        stacked_url += rtmpurl.replace(',', ',,') + ' , '
    finalurl = stacked_url[:-3]
    xbmcplugin.setResolvedUrl(pluginHandle, True,
                              xbmcgui.ListItem(path=finalurl))
Ejemplo n.º 24
0
def play_video(video_url = _common.args.url):
	stack_url = 'stack://'
	hbitrate = -1
	sbitrate = int(_addoncompat.get_setting('quality')) * 1024
	closedcaption = None
	video_data = _connection.getURL(video_url)
	video_tree = BeautifulSoup(video_data, 'html.parser')
	video_segments = video_tree.find_all('segment')
	for video_segment in video_segments:
		seg_url = VIDEOINFO % video_segment['id']
		seg_data = _connection.getURL(seg_url)
		seg_menu = BeautifulSoup(seg_data).find_all('file')
		hbitrate = -1
		file_url = None
		for video_index in seg_menu:
			try:
				bitrate = int(video_index['bitrate'])
				type = video_index['type']
				if bitrate > hbitrate and bitrate <= sbitrate:
					hbitrate = bitrate
					file_url = video_index.string
				elif bitrate == hbitrate and bitrate <= sbitrate and type == 'hd' :
					file_url = video_index.string
			except:
				pass
		if file_url is None:
			file_url = BeautifulSoup(seg_data).find_all('file',type = 'hd')[0].string
		stack_url += file_url.replace(',', ',,') + ' , '
	finalurl = stack_url[:-3]
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
Ejemplo n.º 25
0
def refresh_db():
    networks = get_networks()
    dialog = xbmcgui.DialogProgress()
    dialog.create(smart_utf8(xbmcaddon.Addon(id=ADDONID).getLocalizedString(39016)))
    total_stations = len(networks)
    current = 0
    increment = 100.0 / total_stations
    for network in networks:
        network_name = network.NAME
        if _addoncompat.get_setting(network.SITE) == "true":
            percent = int(increment * current)
            dialog.update(
                percent,
                smart_utf8(xbmcaddon.Addon(id=ADDONID).getLocalizedString(39017)) + network.NAME,
                smart_utf8(xbmcaddon.Addon(id=ADDONID).getLocalizedString(39018)),
            )
            showdata = network.masterlist()
            total_shows = len(showdata)
            current_show = 0
            for show in showdata:
                percent = int((increment * current) + (float(current_show) / total_shows) * increment)
                dialog.update(
                    percent,
                    smart_utf8(xbmcaddon.Addon(id=ADDONID).getLocalizedString(39017)) + network.NAME,
                    smart_utf8(xbmcaddon.Addon(id=ADDONID).getLocalizedString(39005)) + show[0],
                )
                get_serie(show[0], show[1], show[2], show[3])
                current_show += 1
                if dialog.iscanceled():
                    return False
        current += 1
Ejemplo n.º 26
0
def get_serie(series_title, mode, submode, url, forceRefresh = False):
	command = 'select * from shows where lower(series_title) = ? and mode = ? and submode = ?;'
	values = (series_title.lower(), mode, submode)
	checkdata = _database.execute_command(command, values, fetchone = True)
	empty_values = [series_title, mode,submode, url, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, True, False, False, series_title]
	try:
		tvdb_setting = int(_addoncompat.get_setting('strict_names'))
	except:
		tvdb_setting = 0
	if checkdata and not forceRefresh and checkdata[24]  is not None:
		if checkdata[3] != url: 
			command = 'update shows set url = ? where series_title = ? and mode = ? and submode = ?;'
			values = (url, series_title, mode, submode)
			_database.execute_command(command, values, commit = True)
			command = 'select * from shows where lower(series_title) = ? and mode = ? and submode = ?;'
			values = (series_title.lower(), mode, submode)
			return _database.execute_command(command, values, fetchone = True)
		else:
			return checkdata
	elif tvdb_setting != 1 or forceRefresh:
		tvdb_data = get_tvdb_series(series_title, manualSearch = forceRefresh, site = get_network(mode).NAME)
		if tvdb_data:
			tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, tvdb_series_title = tvdb_data
			values = [series_title, mode, submode, url, tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, True, False, False, tvdb_series_title]
		else:
			values = empty_values
		command = 'insert or replace into shows values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);'
		_database.execute_command(command, values, commit = True)
		command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
		values = (series_title, mode, submode)
		return _database.execute_command(command, values, fetchone = True)
	else:
		return empty_values
def getURL(url,
           values=None,
           referer=False,
           forwardheader=False,
           connectiontype=_addoncompat.get_setting('connectiontype')):
    try:
        old_opener = urllib2._opener
        if int(connectiontype) == 1:
            urllib2.install_opener(prepare_dns_proxy())
        elif int(connectiontype) == 2:
            urllib2.install_opener(prepare_us_proxy())
        elif int(connectiontype) == 3:
            urllib2.install_opener(prepare_tunlr_dns())
        print '_connection :: getURL :: url = ' + url
        if values is None:
            req = urllib2.Request(url)
        else:
            data = urllib.urlencode(values)
            req = urllib2.Request(url, data)
        if referer:
            req.add_header('Referer', referer)
        if forwardheader:
            req.add_header('X-Forwarded-For', forwardheader)
        req.add_header(
            'User-Agent',
            'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20100101 Firefox/14.0.1'
        )
        response = urllib2.urlopen(req)
        link = response.read()
        response.close()
        urllib2.install_opener(old_opener)
    except urllib2.HTTPError, error:
        print 'HTTP Error reason: ', error
        return error.read()
Ejemplo n.º 28
0
def get_serie(series_title, mode, submode, url, forceRefresh = False):
	command = 'select * from shows where lower(series_title) = ? and mode = ? and submode = ?;'
	values = (series_title.lower(), mode, submode)
	checkdata = _database.execute_command(command, values, fetchone = True)
	empty_values = [series_title, mode,submode, url, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, True, False, False, series_title]
	try:
		tvdb_setting = int(_addoncompat.get_setting('strict_names'))
	except:
		tvdb_setting = 0
	if checkdata and not forceRefresh and checkdata[24]  is not None:
		if checkdata[3] != url: 
			command = 'update shows set url = ? where series_title = ? and mode = ? and submode = ?;'
			values = (url, series_title, mode, submode)
			_database.execute_command(command, values, commit = True)
			command = 'select * from shows where lower(series_title) = ? and mode = ? and submode = ?;'
			values = (series_title.lower(), mode, submode)
			return _database.execute_command(command, values, fetchone = True)
		else:
			return checkdata
	elif tvdb_setting != 1 or forceRefresh:
		tvdb_data = get_tvdb_series(series_title, manualSearch = forceRefresh, site = get_network(mode).NAME)
		if tvdb_data:
			tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, tvdb_series_title = tvdb_data
			values = [series_title, mode, submode, url, tvdb_id, imdb_id, tvdbbanner, tvdbposter, tvdbfanart, first_aired, date, year, actors, genres, network, plot, runtime, rating, airs_dayofweek, airs_time, status, True, False, False, tvdb_series_title]
		else:
			values = empty_values
		command = 'insert or replace into shows values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);'
		_database.execute_command(command, values, commit = True)
		command = 'select * from shows where series_title = ? and mode = ? and submode = ?;'
		values = (series_title, mode, submode)
		return _database.execute_command(command, values, fetchone = True)
	else:
		return empty_values
Ejemplo n.º 29
0
def masterlist(SITE, BRANDID):
	master_db = []
	master_data = _connection.getURL(SHOWS % BRANDID)
	master_menu = simplejson.loads(master_data)['shows']['show']
	for master_item in master_menu:
		fullepisodes = 0
		clips = 0
		if (int(master_item['clips']['count']['@total']) + int(master_item['fullepisodes']['count']['@total'])) > 0:
			if int(master_item['clips']['count']['@total']) > 0:
				try:
					if int(master_item['clips']['count']['video']['@accesslevel']) == 0:
						clips = int(master_item['clips']['count']['video']['$'])	
				except:
					if int(master_item['clips']['count']['video'][0]['@accesslevel']) == 0:
						clips = int(master_item['clips']['count']['video'][0]['$'])
			if int(master_item['fullepisodes']['count']['@total']) > 0:
				try:
					if int(master_item['fullepisodes']['count']['video']['@accesslevel']) == 0:
						fullepisodes = int(master_item['fullepisodes']['count']['video']['$'])
				except:
					if int(master_item['fullepisodes']['count']['video'][0]['@accesslevel']) == 0:
						fullepisodes = int(master_item['fullepisodes']['count']['video'][0]['$'])
			if fullepisodes > 0 or (clips > 0 and _addoncompat.get_setting('hide_clip_only') == 'false'):
				master_name = master_item['title'].strip()
				season_url = master_item['@id']
				master_db.append((master_name, SITE, 'seasons', season_url))
	return master_db
Ejemplo n.º 30
0
def play_video(video_url = _common.args.url):
	hbitrate = -1
	sbitrate = int(_addoncompat.get_setting('quality')) * 1024
	closedcaption = None
	video_data = _connection.getURL(video_url)
	video_tree = BeautifulSoup(video_data, 'html.parser')
	finalurl = video_tree.seq.video['src']
	try:
		closedcaption = video_tree.find('textstream', type = 'text/vtt')['src']
	except:
		pass
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
			convert_subtitles(closedcaption)
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 31
0
def play_video(video_url = _common.args.url):
	hbitrate = -1
	sbitrate = int(_addoncompat.get_setting('quality')) * 1024
	closedcaption = None
	video_data = _connection.getURL(video_url)
	video_tree = BeautifulSoup(video_data, 'html.parser')
	finalurl = video_tree.seq.video['src']
	try:
		closedcaption = video_tree.find('textstream', type = 'text/vtt')['src']
	except:
		pass
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
			convert_subtitles(closedcaption)
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 32
0
def play_video(video_url = _common.args.url):
	video_url9 = 'stack://'
	sbitrate = int(_addoncompat.get_setting('quality'))
	closedcaption = None
	video_data = _connection.getURL(video_url, forwardHeader = True)
	try:
		video_url2 = re.compile('<meta content="http://media.nick.com/(.+?)" itemprop="embedURL"/>').findall(video_data)[0]
	except:
		video_url2 = re.compile("NICK.unlock.uri = '(.+?)';").findall(video_data)[0]
	video_url3 = _connection.getRedirect('http://media.nick.com/' + video_url2, referer = BASE, forwardHeader = True)
	video_url4 = urllib.unquote_plus(video_url3.split('CONFIG_URL=')[1].split('&')[0]).strip()
	video_data2 = _connection.getURL(video_url4, referer = 'http://media.nick.com/' + video_url2, forwardHeader = True)
	video_tree = BeautifulSoup(video_data2)
	video_url5 = video_tree.feed.string.replace('{uri}', video_url2).replace('&amp;', '&').replace('{type}', 'network').replace('mode=episode', 'mode=clip')
	video_data3 = _connection.getURL(video_url5,forwardHeader=True)
	video_tree2 = BeautifulSoup(video_data3)
	video_segments = video_tree2.find_all('media:content')
	for video_segment in video_segments:
		hbitrate = -1
		video_url6 = video_segment['url']
		video_data4 = _connection.getURL(video_url6, forwardHeader = True)
		video_menu = BeautifulSoup(video_data4).find_all('rendition')
		for video_index in video_menu:
			bitrate = int(video_index['bitrate'])
			if bitrate > hbitrate and bitrate <= sbitrate:
				hbitrate = bitrate
				video_url7 = video_index.find('src').string
				video_url8 = video_url7 + ' swfurl=' + video_url3.split('?')[0] + ' pageUrl=' + BASE + ' swfvfy=true'
		video_url9 += video_url8.replace(',',',,') + ' , '
	finalurl = video_url9[:-3]
	try:
		closedcaption = video_tree2.find_all('media:text')
	except:
		pass
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
		convert_subtitles(closedcaption)
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		for count in range(1, len(closedcaption)):
			xbmc.Player().setSubtitles(os.path.join(_common.CACHEPATH,'subtitle-%s.srt' % str(count)))
			while xbmc.Player().isPlaying():
				xbmc.sleep(10)
Ejemplo n.º 33
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
            episode_plot = BeautifulSoup(
                video['description']['value']).p.string
            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(_addoncompat.get_setting('maxpages')):
        add_videos_thetonightshow(url, type_, page + 1, added_episodes)
    _common.set_view('episodes')
Ejemplo n.º 34
0
def play_video(video_url = _common.args.url):
	hbitrate=-1
	if _addoncompat.get_setting('enablesubtitles') == 'true':
		convert_subtitles(video_url)
	sbitrate = int(_addoncompat.get_setting('quality'))
	video_data = _connection.getURL(VIDEOURL % video_url)
	video_tree = simplejson.loads(video_data)
	for video_key in video_tree['videos']:
		video_index = video_tree['videos'][video_key]
		bitrate = int(video_index['bitrate'])
		if bitrate > hbitrate and bitrate <= sbitrate:
			hbitrate = bitrate
			playpath_url = video_index['uri'].split('mp4:')[1].replace('Level3', '') 
	finalurl = RTMPURL + ' playpath=mp4:' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true'
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if _addoncompat.get_setting('enablesubtitles') == 'true':
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 35
0
def episodes(episode_url = _common.args.url):
	episode_data = _connection.getURL(episode_url)
	episode_tree = BeautifulSoup(episode_data)
	if 'Video Clips' in _common.args.name :
		episode_url2 = episode_tree.find('div', class_ = 'v_content')['data-url']
		if episode_tree.find('div', class_ = 'pagination') is not None:
			episode_count = int(episode_tree.find('div', class_ = 'result').text.rsplit(' ', 1)[1].strip())
			episode_items, episode_rest = divmod(episode_count, 10)
			if episode_rest > 0:
				episode_items = episode_items + 1
			if episode_items > int(_addoncompat.get_setting('maxpages')):
				episode_items = int(_addoncompat.get_setting('maxpages'))
			for episode_item in range(episode_items):
					episode_data2 = _connection.getURL(episode_url2 + '?page=' + str(episode_item + 1))
					episode_tree2 = BeautifulSoup(episode_data2)
					add_clips(episode_tree2)
		else:
			episode_data2 = _connection.getURL(episode_url2 + '?page=1')
			episode_tree2 = BeautifulSoup(episode_data2)
			add_clips(episode_tree2)
	else:
		try:
			add_fullepisodes(episode_tree, int(_common.args.name.split(' ')[1]))
		except:
			try:
				add_fullepisodes(episode_tree, int(_common.args.name))
			except:
				add_fullepisodes(episode_tree)
		if episode_tree.find('div', class_ = 'pagination') is not None:
			episode_items2 = episode_tree.find('div', class_ = 'pagination').find_all('a')
			for episode_item2 in episode_items2:
				if (episode_item2.text != 'Next'):
					episode_data3 = _connection.getURL(episode_item2['href'])
					episode_tree3 = BeautifulSoup(episode_data3)
					try:
						add_fullepisodes(episode_tree3, int(_common.args.name.split(' ')[1]))
					except:
						try:
							add_fullepisodes(episode_tree3, int(_common.args.name))
						except:
							add_fullepisodes(episode_tree3)
	_common.set_view('episodes')
Ejemplo n.º 36
0
def play_video(video_url=_common.args.url):
    video_url6 = 'stack://'
    sbitrate = int(_addoncompat.get_setting('quality'))
    closedcaption = None
    video_data = _connection.getURL(video_url)
    video_url2 = BeautifulSoup(video_data, 'html5lib').find(
        'div', class_='videoShare')['data-unique-id']
    video_data2 = _connection.getURL(VIDEOURL + video_url2)
    video_tree = BeautifulSoup(video_data2, 'html5lib')
    video_segments = video_tree.find_all('media:content')
    for video_segment in video_segments:
        video_url3 = video_segment['url']
        video_data3 = _connection.getURL(video_url3)
        video_menu = BeautifulSoup(video_data3).findAll('rendition')
        hbitrate = -1
        for video_index in video_menu:
            bitrate = int(video_index['bitrate'])
            if bitrate > hbitrate and bitrate <= sbitrate:
                hbitrate = bitrate
                video_url4 = video_index.find('src').string
                video_url5 = MP4URL + video_url4.split('e20')[1]
        video_url6 += video_url5.replace(',', ',,') + ' , '
    finalurl = video_url6[:-3]
    try:
        closedcaption = video_tree.find_all('media:text')
    except:
        pass
    if (_addoncompat.get_setting('enablesubtitles')
            == 'true') and (closedcaption is not None):
        convert_subtitles(closedcaption)
    xbmcplugin.setResolvedUrl(pluginHandle, True,
                              xbmcgui.ListItem(path=finalurl))
    if (_addoncompat.get_setting('enablesubtitles')
            == 'true') and (closedcaption is not None):
        while not xbmc.Player().isPlaying():
            xbmc.sleep(100)
        for count in range(1, len(closedcaption)):
            xbmc.Player().setSubtitles(
                os.path.join(_common.CACHEPATH,
                             'subtitle-%s.srt' % str(count)))
            while xbmc.Player().isPlaying():
                xbmc.sleep(10)
Ejemplo n.º 37
0
def play_video(video_url = _common.args.url):
	hbitrate = -1
	sbitrate = int(_addoncompat.get_setting('quality')) * 1024
	closedcaption = None
	video_url2 = None
	finalurl = ''
	try:
		closedcaption = simplejson.loads(_connection.getURL(CLOSEDCAPTION % video_url).replace('video_info(', '').replace(')', ''))['closed_captions_url']
	except:
		pass
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''):
		convert_subtitles(closedcaption.replace(' ', '+'))
	video_data = cove.videos.filter(fields = 'mediafiles', filter_tp_media_object_id = video_url)
	video_menu = video_data['results'][0]['mediafiles']
	for video_item in video_menu:
		if video_item['video_encoding']['eeid'] == 'ipad-16x9':
			video_url2 = video_item['video_data_url']
		elif video_item['video_encoding']['eeid'] == 'hls-2500k-16x9':
			video_url2 = video_item['video_data_url']
		else:
			pass
	if video_url2 is None:
		video_url2 = video_item['video_data_url']
	video_data2 = _connection.getURL(video_url2 + '?format=jsonp&callback=jQuery18303874830141490152_1377946043740')
	video_url3 = simplejson.loads(video_data2.replace('jQuery18303874830141490152_1377946043740(', '').replace(')', ''))['url']
	if '.mp4' in video_url3:
		base_url, playpath_url = video_url3.split('mp4:')
		finalurl = base_url +' playpath=mp4:' + playpath_url + '?player= swfurl=' + SWFURL % video_data['results'][0]['guid'] + ' swfvfy=true'
	else:
		video_data3 = _connection.getURL(video_url3)
		video_url4 = _m3u8.parse(video_data3)
		for video_index in video_url4.get('playlists'):
			bitrate = int(video_index.get('stream_info')['bandwidth'])
			if bitrate > hbitrate and bitrate <= sbitrate:
				hbitrate = bitrate
				finalurl = video_url3.rsplit('/', 1)[0] + '/' + video_index.get('uri')
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 38
0
def play_video(video_url = _common.args.url):
	hbitrate = -1
	sbitrate = int(_addoncompat.get_setting('quality')) * 1024
	closedcaption = None
	video_url2 = None
	finalurl = ''
	try:
		closedcaption = simplejson.loads(_connection.getURL(CLOSEDCAPTION % video_url).replace('video_info(', '').replace(')', ''))['closed_captions_url']
	except:
		pass
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''):
		convert_subtitles(closedcaption.replace(' ', '+'))
	video_data = cove.videos.filter(fields = 'mediafiles', filter_tp_media_object_id = video_url)
	video_menu = video_data['results'][0]['mediafiles']
	for video_item in video_menu:
		if video_item['video_encoding']['eeid'] == 'ipad-16x9':
			video_url2 = video_item['video_data_url']
		elif video_item['video_encoding']['eeid'] == 'hls-2500k-16x9':
			video_url2 = video_item['video_data_url']
		else:
			pass
	if video_url2 is None:
		video_url2 = video_item['video_data_url']
	video_data2 = _connection.getURL(video_url2 + '?format=jsonp&callback=jQuery18303874830141490152_1377946043740')
	video_url3 = simplejson.loads(video_data2.replace('jQuery18303874830141490152_1377946043740(', '').replace(')', ''))['url']
	if '.mp4' in video_url3:
		base_url, playpath_url = video_url3.split('mp4:')
		finalurl = base_url +' playpath=mp4:' + playpath_url + '?player= swfurl=' + SWFURL % video_data['results'][0]['guid'] + ' swfvfy=true'
	else:
		video_data3 = _connection.getURL(video_url3)
		video_url4 = _m3u8.parse(video_data3)
		for video_index in video_url4.get('playlists'):
			bitrate = int(video_index.get('stream_info')['bandwidth'])
			if bitrate > hbitrate and bitrate <= sbitrate:
				hbitrate = bitrate
				finalurl = video_url3.rsplit('/', 1)[0] + '/' + video_index.get('uri')
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None) and (closedcaption != ''):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 39
0
def play_video(video_url=_common.args.url):
    hbitrate = -1
    if _addoncompat.get_setting('enablesubtitles') == 'true':
        convert_subtitles(video_url)
    sbitrate = int(_addoncompat.get_setting('quality'))
    video_data = _connection.getURL(VIDEOURL % video_url)
    video_tree = simplejson.loads(video_data)
    for video_key in video_tree['videos']:
        video_index = video_tree['videos'][video_key]
        bitrate = int(video_index['bitrate'])
        if bitrate > hbitrate and bitrate <= sbitrate:
            hbitrate = bitrate
            playpath_url = video_index['uri'].split('mp4:')[1].replace(
                'Level3', '')
    finalurl = RTMPURL + ' playpath=mp4:' + playpath_url + ' swfurl=' + SWFURL + ' swfvfy=true'
    xbmcplugin.setResolvedUrl(pluginHandle, True,
                              xbmcgui.ListItem(path=finalurl))
    if _addoncompat.get_setting('enablesubtitles') == 'true':
        while not xbmc.Player().isPlaying():
            xbmc.sleep(100)
        xbmc.Player().setSubtitles(SUBTITLE)
Ejemplo n.º 40
0
def getURL(url,
           values=None,
           header={},
           amf=False,
           savecookie=False,
           loadcookie=False,
           connectiontype=_addoncompat.get_setting('connectiontype')):
    try:
        old_opener = urllib2._opener
        cj = cookielib.LWPCookieJar(COOKIE)
        if int(connectiontype) == 0:
            opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
            urllib2.install_opener(opener)
        if int(connectiontype) == 1:
            urllib2.install_opener(prepare_dns_proxy(cj))
        elif int(connectiontype) == 2:
            urllib2.install_opener(prepare_us_proxy(cj))
        print '_connection :: getURL :: url = ' + url
        if values is None:
            req = urllib2.Request(bytes(url))
        else:
            if amf == False:
                data = urllib.urlencode(values)
            elif amf == True:
                data = values
            req = urllib2.Request(bytes(url), data)
        header.update({
            'User-Agent':
            'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0'
        })
        for key, value in header.iteritems():
            req.add_header(key, value)
        if loadcookie is True:
            try:
                cj.load(ignore_discard=True)
                cj.add_cookie_header(req)
            except:
                print 'Cookie Loading Error'
                pass
        response = urllib2.urlopen(req)
        link = response.read()
        if savecookie is True:
            try:
                cj.save(ignore_discard=True)
            except:
                print 'Cookie Saving Error'
                pass
        response.close()
        urllib2.install_opener(old_opener)
    except urllib2.HTTPError, error:
        print 'HTTP Error reason: ', error
        return error.read()
Ejemplo n.º 41
0
def play_video(video_url = _common.args.url):
	try:
		qbitrate = _common.args.quality
	except:
		qbitrate = None
	hbitrate = -1
	hpath = None
	sbitrate = int(_addoncompat.get_setting('quality'))
	closedcaption = video_url.split('#')[1]
	video_url = video_url.split('#')[0]
	if qbitrate is None:
		lbitrate = -1
		for quality_index in QUALITIES:
			bitrate = int(quality_index[0])
			if bitrate < lbitrate or lbitrate == -1:
				lbitrate = bitrate
				lpath = quality_index[1]	
			if bitrate > hbitrate and bitrate <= sbitrate:
				hbitrate = bitrate
				hpath = quality_index[1]	
		if hpath is None:
			hpath = lpath
	else:
		hpath = qbitrate	
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption != ''):
			convert_subtitles(closedcaption)
	finalurl = video_url + hpath
	item = xbmcgui.ListItem(path = finalurl)
	if qbitrate is not None:
		item.setThumbnailImage(_common.args.thumb)
		item.setInfo('Video', {	'title' : _common.args.name,
								'season' : _common.args.season_number,
								'episode' : _common.args.episode_number,
								'TVShowTitle' : _common.args.show_title })
	xbmcplugin.setResolvedUrl(pluginHandle, True, item)
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption != ''):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 42
0
def play_video(video_url = _common.args.url):
	try:
		qbitrate = _common.args.quality
	except:
		qbitrate = None
	hbitrate = -1
	hpath = None
	sbitrate = int(_addoncompat.get_setting('quality'))
	closedcaption = video_url.split('#')[1]
	video_url = video_url.split('#')[0]
	if qbitrate is None:
		lbitrate = -1
		for quality_index in QUALITIES:
			bitrate = int(quality_index[0])
			if bitrate < lbitrate or lbitrate == -1:
				lbitrate = bitrate
				lpath = quality_index[1]	
			if bitrate > hbitrate and bitrate <= sbitrate:
				hbitrate = bitrate
				hpath = quality_index[1]	
		if hpath is None:
			hpath = lpath
	else:
		hpath = qbitrate	
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption != ''):
			convert_subtitles(closedcaption)
	finalurl = video_url + hpath
	item = xbmcgui.ListItem(path = finalurl)
	if qbitrate is not None:
		item.setThumbnailImage(_common.args.thumb)
		item.setInfo('Video', {	'title' : _common.args.name,
								'season' : _common.args.season_number,
								'episode' : _common.args.episode_number,
								'TVShowTitle' : _common.args.show_title })
	xbmcplugin.setResolvedUrl(pluginHandle, True, item)
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption != ''):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		xbmc.Player().setSubtitles(_common.SUBTITLE)
Ejemplo n.º 43
0
def getRedirect(url, values = None , header = {}, connectiontype = _addoncompat.get_setting('connectiontype')):
	try:
		old_opener = urllib2._opener
		cj = cookielib.LWPCookieJar(COOKIE)
		cookie_handler = urllib2.HTTPCookieProcessor(cj)
		if int(connectiontype) == 1:
			urllib2.install_opener(prepare_dns_proxy(cookie_handler))
		elif int(connectiontype) == 2:
			urllib2.install_opener(prepare_us_proxy(cookie_handler))
		elif int(connectiontype) == 3:
			handler = TorHandler()
			if ((_addoncompat.get_setting('tor_use_local') == 'true') and _addoncompat.get_setting('tor_as_service') == 'false'):
				if not handler.start_tor():
					print 'Error launching Tor. It may already be running.\n'
			urllib2.install_opener(prepare_tor_proxy(cookie_handler))
		print '_connection :: getRedirect :: url = ' + url
		if values is None:
			req = urllib2.Request(bytes(url))
		else:
			data = urllib.urlencode(values)
			req = urllib2.Request(bytes(url), data)
		header.update({'User-Agent' : 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0'})
		if connectiontype == 2:
			header.update({'X-Forwarded-For' : _addoncompat.get_setting('us_proxy')})
		for key, value in header.iteritems():
			req.add_header(key, value)
		response = urllib2.urlopen(req, timeout = TIMEOUT)
		finalurl = response.geturl()
		response.close()
		if ((int(connectiontype) == 3) and (_addoncompat.get_setting('tor_use_local') == 'true') and (_addoncompat.get_setting('tor_as_service') == 'false')):
			if not handler.kill_tor(): 
				print 'Error killing Tor process! It may still be running.\n' 
			else: 
				print 'Tor instance killed!\n'
		urllib2.install_opener(old_opener)
	except urllib2.HTTPError, error:
		print 'HTTP Error reason: ', error
		return error.read()
Ejemplo n.º 44
0
def masterlist():
	master_db = []
	master_dict = {}
	master_url = SHOWS
	master_data = _connection.getURL(master_url)
	master_menu = simplejson.loads(master_data)['Entries']
	for master_item in master_menu:
		if _addoncompat.get_setting('hide_clip_only') == 'false' or not master_item.get('ClipsOnly', False):
			master_name = master_item['Title']
			season_url = FULLEPISODES % master_item['ID']
			master_dict[master_name] = season_url
			master_db.append((master_name, SITE, 'seasons', season_url))
	master_db.append(('--Crackle Movies', SITE, 'movielist', MOVIES))
	return master_db
Ejemplo n.º 45
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(_addoncompat.get_setting('maxpages')):
		add_videos_thetonightshow(url, type_, page + 1, added_episodes)
	_common.set_view('episodes')
Ejemplo n.º 46
0
def play_video(SITE):
    video_url = _common.args.url
    try:
        qbitrate = _common.args.quality
    except:
        qbitrate = None
    hbitrate = -1
    lbitrate = -1
    sbitrate = int(_addoncompat.get_setting('quality'))
    video_data = _connection.getURL(video_url)
    smil_url = re.compile("window.video_auth_playlist_url = '(.*)'").findall(
        video_data)[0]
    smil_data = _connection.getURL(smil_url + '&manifest=m3u')
    video_tree2 = BeautifulSoup(smil_data)
    video_url3 = video_tree2.video['src']
    video_data3 = _connection.getURL(video_url3)
    video_url4 = _m3u8.parse(video_data3)
    video_url5 = None
    for video_index in video_url4.get('playlists'):
        bitrate = int(video_index.get('stream_info')['bandwidth'])
        if qbitrate is None:
            try:
                codecs = video_index.get('stream_info')['codecs']
            except:
                codecs = ''
            if (bitrate < lbitrate
                    or lbitrate == -1) and 'mp4a.40.2' != codecs:
                lbitrate = bitrate
                lvideo_url5 = video_index.get('uri')
            if bitrate > hbitrate and bitrate <= (
                    sbitrate * 1000) and codecs != 'mp4a.40.2':
                hbitrate = bitrate
                video_url5 = video_index.get('uri')
        elif bitrate == qbitrate:
            video_url5 = video_index.get('uri')
    if video_url5 is None:
        video_url5 = lvideo_url5
    finalurl = video_url3.rsplit('/', 1)[0] + '/' + video_url5
    item = xbmcgui.ListItem(path=finalurl)
    if qbitrate is not None:
        item.setThumbnailImage(_common.args.thumb)
        item.setInfo(
            'Video', {
                'title': _common.args.name,
                'season': _common.args.season_number,
                'episode': _common.args.episode_number,
                'TVShowTitle': _common.args.show_title
            })
    xbmcplugin.setResolvedUrl(pluginHandle, True, item)
Ejemplo n.º 47
0
def play_video(video_url = _common.args.url):
	video_url6 = 'stack://'
	sbitrate = int(_addoncompat.get_setting('quality'))
	closedcaption = None
	video_data = _connection.getURL(video_url)
	video_url2 = BeautifulSoup(video_data, 'html5lib').find('div', class_ = 'videoShare')['data-unique-id']
	video_data2 = _connection.getURL(VIDEOURL + video_url2)
	video_tree = BeautifulSoup(video_data2, 'html5lib')
	video_segments = video_tree.find_all('media:content')
	for video_segment in video_segments:
		video_url3 = video_segment['url']
		video_data3 = _connection.getURL(video_url3)
		video_menu = BeautifulSoup(video_data3).findAll('rendition')
		hbitrate = -1
		for video_index in video_menu:
			bitrate = int(video_index['bitrate'])
			if bitrate > hbitrate and bitrate <= sbitrate:
				hbitrate = bitrate
				video_url4 = video_index.find('src').string
				video_url5 = MP4URL + video_url4.split('e20')[1]
		video_url6 += video_url5.replace(',',',,')+' , '
	finalurl = video_url6[:-3]
	try:
		closedcaption = video_tree.find_all('media:text')
	except:
		pass
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
		convert_subtitles(closedcaption)
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
	if (_addoncompat.get_setting('enablesubtitles') == 'true') and (closedcaption is not None):
		while not xbmc.Player().isPlaying():
			xbmc.sleep(100)
		for count in range(1, len(closedcaption)):
			xbmc.Player().setSubtitles(os.path.join(_common.CACHEPATH,'subtitle-%s.srt' % str(count)))
			while xbmc.Player().isPlaying():
				xbmc.sleep(10)
def play_video(SITE):
    video_url = _common.args.url
    try:
        qbitrate = _common.args.quality
    except:
        qbitrate = None
    hbitrate = -1
    lbitrate = -1
    sbitrate = int(_addoncompat.get_setting("quality"))
    video_data = _connection.getURL(video_url)
    smil_url = re.compile("window.video_auth_playlist_url = '(.*)'").findall(video_data)[0]
    smil_data = _connection.getURL(smil_url + "&manifest=m3u")
    video_tree2 = BeautifulSoup(smil_data)
    video_url3 = video_tree2.video["src"]
    video_data3 = _connection.getURL(video_url3)
    video_url4 = _m3u8.parse(video_data3)
    video_url5 = None
    for video_index in video_url4.get("playlists"):
        bitrate = int(video_index.get("stream_info")["bandwidth"])
        if qbitrate is None:
            try:
                codecs = video_index.get("stream_info")["codecs"]
            except:
                codecs = ""
            if (bitrate < lbitrate or lbitrate == -1) and "mp4a.40.2" != codecs:
                lbitrate = bitrate
                lvideo_url5 = video_index.get("uri")
            if bitrate > hbitrate and bitrate <= (sbitrate * 1000) and codecs != "mp4a.40.2":
                hbitrate = bitrate
                video_url5 = video_index.get("uri")
        elif bitrate == qbitrate:
            video_url5 = video_index.get("uri")
    if video_url5 is None:
        video_url5 = lvideo_url5
    finalurl = video_url3.rsplit("/", 1)[0] + "/" + video_url5
    item = xbmcgui.ListItem(path=finalurl)
    if qbitrate is not None:
        item.setThumbnailImage(_common.args.thumb)
        item.setInfo(
            "Video",
            {
                "title": _common.args.name,
                "season": _common.args.season_number,
                "episode": _common.args.episode_number,
                "TVShowTitle": _common.args.show_title,
            },
        )
    xbmcplugin.setResolvedUrl(pluginHandle, True, item)
Ejemplo n.º 49
0
def add_video(video_url, displayname, thumb = None, fanart = None, infoLabels = False, HD = False, quality_mode = False):
	displayname = smart_utf8(replace_signs(smart_unicode(displayname)))
	if fanart is None:
		if args.__dict__.has_key('fanart'):
			fanart = args.fanart
		else:
			fanart = PLUGINFANART
	if thumb is None:
		if args.__dict__.has_key('thumb'):
			thumb = args.thumb
		else:
			thumb = ''
	if 'episode' in infoLabels.keys() and 'season' in infoLabels.keys() and _addoncompat.get_setting('add_episode_identifier') == 'true':
			displayname = 'S' + str(infoLabels['season']).zfill(2) + 'E' + str(infoLabels['episode']).zfill(2) + ' - ' + displayname
	item = xbmcgui.ListItem(displayname, iconImage = thumb, thumbnailImage = thumb)
	item.setInfo(type = 'Video', infoLabels = infoLabels)
	try:
		if 'durationinseconds' in infoLabels.keys():	
			duration = infoLabels['durationinseconds']
		else:
			duration = 0
		if HD is True:
			item.addStreamInfo('video', {'codec' : 'h264', 'width' : 1280, 'height' : 720, 'duration' : duration})
		else:
			item.addStreamInfo('video', {'codec' : 'h264', 'width' : 720, 'height' : 400, 'duration' : duration})
		item.addStreamInfo('audio', {'codec': 'aac', 'channels' : 2})
	except:
		pass
	item.setProperty('fanart_image', fanart)
	item.setProperty('IsPlayable', 'true')
	if quality_mode:
		contextmenu = []
		if 'episode' in infoLabels.keys():	
			episode = infoLabels['episode']
		else:
			episode = -1
		if 'season' in infoLabels.keys():	
			season = infoLabels['season']
		else:
			season = -1
		if 'TVShowTitle' in infoLabels.keys():
			show_title = infoLabels['TVShowTitle']
		else:
			show_title = ''
		quailty_u = sys.argv[0] + '?url='+ urllib.quote_plus('<join>'.join([show_title, str(season), str(episode), thumb, base64.b64encode(displayname), quality_mode, video_url])) +'&mode=_contextmenu' + '&sitemode=select_quality' 
		contextmenu.append((smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39022)), 'XBMC.PlayMedia(%s)' % quailty_u))
		item.addContextMenuItems(contextmenu)
	xbmcplugin.addDirectoryItem(pluginHandle, url = video_url, listitem = item, isFolder = False)
Ejemplo n.º 50
0
def play_video(video_url = _common.args.url):
	hbitrate = -1
	sbitrate = int(_addoncompat.get_setting('quality'))
	video_data = _connection.getURL(video_url)
	video_tree = BeautifulSoup(video_data)
	video_url2 = video_tree.find('video', id = 'ngs_player')('source')[0]['src']
	video_data2 = _connection.getURL(video_url2.replace('&format=redirect', ''))
	video_tree2 = BeautifulSoup(video_data2)
	video_url3 = video_tree2.video['src']
	video_data3 = _connection.getURL(video_url3)
	video_url4 = _m3u8.parse(video_data3)
	for video_index in video_url4.get('playlists'):
		bitrate = int(video_index.get('stream_info')['bandwidth'])
		if bitrate > hbitrate and bitrate <= (sbitrate * 1000):
			hbitrate = bitrate
			finalurl = video_url3.rsplit('/',1)[0] + '/' + video_index.get('uri')
	xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
Ejemplo n.º 51
0
def play_video(video_url=_common.args.url):
    hbitrate = -1
    sbitrate = int(_addoncompat.get_setting('quality')) * 1000
    finalurl = ''
    video_data = _connection.getURL(video_url + '&manifest=m3u')
    video_tree = BeautifulSoup(video_data)

    video_url2 = video_tree.find('video', src=True)['src']
    signature = FOXsig(_common.args.url)
    print signature
    video_data2 = _connection.getFox(
        video_url2,
        header={'Cookie': signature},
        referer='http://player.foxfdm.com/shared/1.4.522/pdk/swf/akamaiHD.swf')
    print video_data2
    video_menu = _m3u8.parse(video_data2)
    for video_index in video_menu.get('playlists'):
        bitrate = int(video_index.get('stream_info')['bandwidth'])
        if bitrate > hbitrate and bitrate <= sbitrate:
            hbitrate = bitrate
            video_url3 = video_index.get('uri').replace('%2f', '')
    video_data3 = re.sub(r"\#EXT-X-DISCONTINUITY\n", "",
                         _connection.getURL(video_url3))
    keyurl = re.compile('URI="(.*?)"').findall(video_data3)[0]
    key_data = _connection.getURL(keyurl)
    keyfile = open(KEYPATH, 'w')
    keyfile.write(key_data)
    keyfile.close()
    localhttpserver = True
    filestring = 'XBMC.RunScript(' + os.path.join(
        _common.LIBPATH, '_proxy.py') + ',' + KEYPATH + ', 12345)'
    xbmc.executebuiltin(filestring)
    time.sleep(2)
    newkeyurl = 'http://127.0.0.1:12345'
    video_data4 = video_data4.replace(keyurl, newkeyurl)
    playfile = open(PLAYPATH, 'w')
    playfile.write(video_data4)
    playfile.close()
    finalurl = PLAYPATH
    xbmcplugin.setResolvedUrl(pluginHandle, True,
                              xbmcgui.ListItem(path=finalurl))
    if localhttpserver is True:
        _connection.getURL('http://localhost:12345/stop', connectiontype=0)
Ejemplo n.º 52
0
def load_showlist(favored = 0):
	if not os.path.exists(_database.DBFILE):
		_database.create_db()
		refresh_db()
	elif not favored:
		refresh = False
		command = 'select distinct mode from shows order by mode'
		modes = _database.execute_command(command, fetchall = True)
		mode_list = [element[0] for element in modes]
		for network in get_networks():
			if _addoncompat.get_setting(network.SITE) == 'true' and network.SITE not in mode_list:
				refresh = True
		if refresh:
			refresh_db()
	_database.check_db_version()
	command = "select * from shows  where url <> '' and hide <> 1 and favor = ? order by series_title"
	shows = _database.execute_command(command, fetchall = True, values = [favored]) 
	for show in shows:
		add_show( masterList = True, showdata = show)	
def getAMF(url,
           values,
           header,
           connectiontype=_addoncompat.get_setting('connectiontype')):
    try:
        old_opener = urllib2._opener
        if int(connectiontype) == 1:
            urllib2.install_opener(prepare_dns_proxy())
        elif int(connectiontype) == 2:
            urllib2.install_opener(prepare_us_proxy())
        elif int(connectiontype) == 3:
            urllib2.install_opener(prepare_tunlr_dns())
        print '_connection :: getAMF :: url = ' + url
        req = urllib2.Request(url, values, header)
        response = urllib2.urlopen(req)
        link = response.read()
        response.close()
        urllib2.install_opener(old_opener)
    except urllib2.HTTPError, error:
        print 'HTTP Error reason: ', error
        return error.read()
Ejemplo n.º 54
0
def refresh_db():
	if not os.path.isfile(_database.DBFILE):
		print "Creating db"
		_database.create_db()
	networks = get_networks()
	dialog = xbmcgui.DialogProgress()
	dialog.create(smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39016)))
	total_stations = len(networks)
	current = 0
	increment = 100.0 / total_stations
	all_shows = []
	for network in networks:
		network_name = network.NAME
		if _addoncompat.get_setting(network.SITE) == 'true':
			percent = int(increment * current)
			dialog.update(percent, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39017)) + network.NAME, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39018)))
			showdata = network.masterlist()
			for show in showdata:
				series_title, mode, submode, url = show
				all_shows.append((smart_unicode(series_title.lower().strip()), smart_unicode(mode), smart_unicode(submode)))
			total_shows = len(showdata)
			current_show = 0
			for show in showdata:
				percent = int((increment * current) + (float(current_show) / total_shows) * increment)
				dialog.update(percent, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39017)) + network.NAME, smart_utf8(xbmcaddon.Addon(id = ADDONID).getLocalizedString(39005)) + show[0])
				get_serie(show[0], show[1], show[2], show[3], forceRefresh = False)
				current_show += 1
				if (dialog.iscanceled()):
					return False
		current += 1
	command = 'select tvdb_series_title , series_title, mode, submode, url from shows order by series_title'
	shows = _database.execute_command(command, fetchall = True) 
	for show in shows:
		tvdb_series_title, series_title, mode, submode, url = show
		if ((smart_unicode(series_title.lower().strip()),smart_unicode(mode), smart_unicode(submode)) not in all_shows and (smart_unicode(tvdb_series_title.lower().strip()),smart_unicode(mode), smart_unicode(submode)) not in all_shows):
			command = 'delete from shows where series_title = ? and mode = ? and submode = ? and url = ?;'
			values = (series_title, mode, submode, url)
			print "Deleting - " + series_title + " " + mode + " " + submode + " " + url
			_database.execute_command(command, values, fetchone = True, commit = True)
def list_qualities():
	exception = False
	video_url = _common.args.url
	bitrates = []
	sbitrate = int(_addoncompat.get_setting('quality')) * 1024
	closedcaption = None
	video_data = _connection.getURL(video_url)
	video_tree = BeautifulSoup(video_data, 'html.parser')
	video_rtmp = video_tree.meta
	if video_rtmp is not None:
		for video_index in video_url2:
			bitrate = int(video_index['system-bitrate'])
			display = int(bitrate)
			bitrates.append((display, bitrate))
	else:
		video_data = _connection.getURL(video_url + '&manifest=m3u')
		video_tree = BeautifulSoup(video_data,'html5lib')
		if  video_tree.find('param', attrs = {'name' : 'isException', 'value' : 'true'}) is None:
			video_url2 = video_tree.seq.find_all('video')[0]
			video_url3 = video_url2['src']
			video_data2 = _connection.getURL(video_url3)
			video_url5 = _m3u8.parse(video_data2)
			for video_index in video_url5.get('playlists'):
				bitrate = int(video_index.get('stream_info')['bandwidth'])
				try:
					codecs =  video_index.get('stream_info')['codecs']
				except:
					codecs = ''
				display = int(bitrate) / 1024
				if 'mp4a.40.2' not in codecs:
					bitrates.append((display, bitrate))
		else:
			exception = True
	if  not exception:
		return bitrates
	else:
		dialog = xbmcgui.Dialog()
		dialog.ok("Exception", video_tree.ref['title'], video_tree.ref['abstract'])
		return []
def prepare_us_proxy():
    us_proxy = 'http://' + _addoncompat.get_setting(
        'us_proxy') + ':' + _addoncompat.get_setting('us_proxy_port')
    proxy_handler = urllib2.ProxyHandler({'http': us_proxy})
    if ((_addoncompat.get_setting('us_proxy_pass') is not '')
            and (_addoncompat.get_setting('us_proxy_user') is not '')):
        print 'Using authenticated proxy: ' + us_proxy
        password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
        password_mgr.add_password(None, us_proxy,
                                  _addoncompat.get_setting('us_proxy_user'),
                                  _addoncompat.get_setting('us_proxy_pass'))
        proxy_auth_handler = urllib2.ProxyBasicAuthHandler(password_mgr)
        opener = urllib2.build_opener(proxy_handler, proxy_auth_handler)
    else:
        print 'Using proxy: ' + us_proxy
        opener = urllib2.build_opener(proxy_handler)
    return opener
Ejemplo n.º 57
0
def refresh_db():
    networks = get_networks()
    dialog = xbmcgui.DialogProgress()
    dialog.create(
        smart_utf8(xbmcaddon.Addon(id=ADDONID).getLocalizedString(39016)))
    total_stations = len(networks)
    current = 0
    increment = 100.0 / total_stations
    for network in networks:
        network_name = network.NAME
        if _addoncompat.get_setting(network.SITE) == 'true':
            percent = int(increment * current)
            dialog.update(
                percent,
                smart_utf8(
                    xbmcaddon.Addon(id=ADDONID).getLocalizedString(39017)) +
                network.NAME,
                smart_utf8(
                    xbmcaddon.Addon(id=ADDONID).getLocalizedString(39018)))
            showdata = network.masterlist()
            total_shows = len(showdata)
            current_show = 0
            for show in showdata:
                percent = int((increment * current) +
                              (float(current_show) / total_shows) * increment)
                dialog.update(
                    percent,
                    smart_utf8(
                        xbmcaddon.Addon(id=ADDONID).getLocalizedString(39017))
                    + network.NAME,
                    smart_utf8(
                        xbmcaddon.Addon(id=ADDONID).getLocalizedString(39005))
                    + show[0])
                get_serie(show[0], show[1], show[2], show[3])
                current_show += 1
                if (dialog.iscanceled()):
                    return False
        current += 1
Ejemplo n.º 58
0
def play_old():
    videoPlayer = int(common.args.url)
    const = '17e0633e86a5bc4dd47877ce3e556304d0a3e7ca'
    playerID = 644436256001
    publisherID = 51296410001
    rtmpdata = get_clip_info(const, playerID, videoPlayer, publisherID)
    print rtmpdata
    rtmpdata = rtmpdata['renditions']
    hbitrate = -1
    sbitrate = int(_addoncompat.get_setting('quality')) * 1024
    for item in rtmpdata:
        bitrate = int(item['encodingRate'])
        if bitrate > hbitrate and bitrate <= sbitrate:
            hbitrate = bitrate
            urldata = item['defaultURL']
            auth = urldata.split('?')[1]
            urldata = urldata.split('&')
            rtmp = urldata[0] + '?' + auth
            playpath = urldata[1].split('?')[0] + '?' + auth
    swfUrl = 'http://admin.brightcove.com/viewer/us1.25.03.01.2011-05-12131832/federatedVideo/BrightcovePlayer.swf'
    rtmpurl = rtmp + ' playpath=' + playpath + " swfurl=" + swfUrl + " swfvfy=true"
    item = xbmcgui.ListItem(path=rtmpurl)
    xbmcplugin.setResolvedUrl(pluginHandle, True, item)