Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*
- import xbmcplugin
- import xbmc
- import xbmcgui
- import urllib
- import sys
- import re
- import os
- from BeautifulSoup import BeautifulStoneSoup
- import resources.lib._common as common
- import resources.lib.m3u8 as m3u8
- import base64
- pluginHandle = int(sys.argv[1])
- BRANDID = '001'
- PARTNERID = '585231'
- SITE = 'abc'
- SHOWLIST = 'http://abc.go.com/vp2/ws/s/contents/2012/shows/' + BRANDID + '/001/-1?rand=2.0.0000'
- VIDEOLIST = 'http://abc.go.com/vp2/ws/s/contents/2012/videos/' + BRANDID + '/001/'
- def masterlist():
- return rootlist(db=True)
- def rootlist(db=False):
- root_data = common.getURL(SHOWLIST)
- root_tree = BeautifulStoneSoup(root_data, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
- root_menu = root_tree.findAll('show')
- db_shows = []
- for root_item in root_menu:
- root_name = root_item('title')[0].string
- season_id = root_item['id']
- if db == True:
- db_shows.append(root_name, SITE,'seasons',season_id)
- else:
- common.addShow(root_name, SITE,'seasons',season_id)
- if db == True:
- return db_shows
- else:
- common.setView('tvshows')
- def seasons(url=common.args.url):
- show_id = url
- show_url = VIDEOLIST + 'lf/' + show_id + '/-1/-1/-1/-1?rand=2.0.0000'
- show_data = common.getURL(show_url)
- show_menu = sorted(set(re.findall(r'<season id\=\"(.+?)\"',show_data)))
- for show_item in show_menu:
- show_name = 'Season ' + show_item
- show_url = VIDEOLIST + 'lf/' + show_id + '/' + show_item + '/-1/-1/-1?rand=2.0.0000'
- common.addDirectory(show_name, SITE, 'episodes', show_url)
- clip_id = url
- clip_url = VIDEOLIST + 'sf/' + show_id + '/-1/-1/-1/-1?rand=2.0.0000'
- clip_data = common.getURL(clip_url)
- clip_menu = sorted(set(re.findall(r'<season id\=\"(.+?)\"',clip_data)))
- for clip_item in clip_menu:
- clip_name = 'Clips Season ' + clip_item
- clip_url = VIDEOLIST + 'sf/' + clip_id + '/' + clip_item + '/-1/-1/-1?rand=2.0.0000'
- common.addDirectory(clip_name, SITE, 'episodes', clip_url)
- common.setView('seasons')
- def episodes(url=common.args.url):
- episode_data = common.getURL(url)
- episode_tree = BeautifulStoneSoup(episode_data, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
- episode_menu = episode_tree.findAll('video')
- for episode_item in episode_menu:
- episode_name = episode_item('title')[1].string
- try:
- episode_thumb = episode_item('thumbnails')[1]('thumbnail')[1].string
- except:
- try:
- episode_thumb = episode_item('thumbnails')[1]('thumbnail')[0].string
- except:
- episode_thumb = episode_item('thumbnail')[0].string
- if (episode_item('asset')[0]['format'] == 'MOV'):
- sitemode = 'playVideoMOV'
- elif (episode_item('asset')[0]['format'] == 'MP4'):
- sitemode = 'playVideoMP4'
- else:
- sitemode = 'playVideoUPL'
- url = episode_item['id']
- try:
- description = episode_item('longdescription')[0].string
- except:
- description = episode_item('description')[0].string
- episode_airDate = re.sub(r" P(.)T","",episode_item('airdate')[0].string)
- episode_duration = int(episode_item('duration')[0].string)/60000
- episode_number = episode_item('number')[0].string
- season_number = episode_item('season')[0]['id']
- u = sys.argv[0]
- u += '?url="' + urllib.quote_plus(url) + '"'
- u += '&mode="' + SITE + '"'
- u += '&sitemode="' + sitemode + '"'
- infoLabels={ "Title":episode_name,
- "Plot":description,
- "premiered":common.formatDate(episode_airDate,'%a, %d %b %Y %H:%M:%S','%d.%m.%Y'),
- "Duration":episode_duration,
- "Episode":episode_number,
- "Season":season_number
- }
- common.addVideo(u,episode_name,episode_thumb,infoLabels=infoLabels)
- common.setView('episodes')
- def playVideoMOV(url=common.args.url):
- video_id = url.replace('VDKA', '')
- hbitrate = -1
- sbitrate = int(common.settings['quality'])
- video_url = 'http://www.kaltura.com/p/' + PARTNERID + '/sp/' + PARTNERID + '00/playManifest/format/rtmp/entryId/' + video_id
- video_data = common.getURL(video_url)
- video_tree = BeautifulStoneSoup(video_data, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
- base_url = video_tree('baseurl')[0].string
- video_url2 = video_tree.findAll('media')
- for video_index in video_url2:
- bitrate = int(video_index['bitrate'])
- if bitrate > hbitrate and bitrate <= sbitrate:
- hbitrate = bitrate
- playpath_url = video_index['url']
- swf_url = 'http://livepassdl.conviva.com/ver/2.61.0.65970/LivePassModuleMain.swf'
- finalurl = base_url + ' playpath=' + playpath_url + ' swfUrl=' + swf_url + ' swfVfy=true'
- xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path = finalurl))
- def playVideoMP4(url=common.args.url):
- video_id = url.replace('VDKA', '')
- hbitrate = -1
- sbitrate = int(common.settings['quality'])
- video_url = 'http://www.kaltura.com/p/' + PARTNERID + '/sp/' + PARTNERID + '00/playManifest/format/applehttp/entryId/' + video_id
- video_data = common.getURL(video_url)
- video_url2 = m3u8.parse(video_data)
- for video_index in video_url2.get('playlists'):
- bitrate = int(video_index.get('stream_info')['bandwidth'])
- if bitrate > hbitrate and bitrate <= (sbitrate * 1000):
- hbitrate = bitrate
- finalurl = video_index.get('uri')
- xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path=finalurl))
- def playVideoUPL(url=common.args.url):
- video_id = url.replace('VDKA', '')
- hbitrate = -1
- sbitrate = int(common.settings['quality'])
- video_url = 'http://www.kaltura.com/p/' + PARTNERID + '/sp/' + PARTNERID + '00/playManifest/format/http/entryId/' + video_id + '/a.f4m?playbackContext=brand%3D' + BRANDID + '%26device%3D001'
- video_data = common.getURL(video_url)
- video_tree = BeautifulStoneSoup(video_data, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
- video_url2 = video_tree.find('media')['url']
- video_data2 = common.getURL(video_url2)
- 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 * 1000):
- hbitrate = bitrate
- finalurl = video_index.get('uri')
- xbmcplugin.setResolvedUrl(pluginHandle, True, xbmcgui.ListItem(path=finalurl))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement