def get_sb_url(): prot = xbmcplugin.getSetting(handle, "prot") if(prot == "0"): sbUrl = "http://" elif(prot == "1"): sbUrl = "https://" host = xbmcplugin.getSetting(handle, "host") sbUrl += host port = xbmcplugin.getSetting(handle, "port") sbUrl += ":" + port web_root = xbmcplugin.getSetting(handle, "web_root") if (web_root!="/"): sbUrl += web_root sbUrl += "/api/" guid = xbmcplugin.getSetting(handle, "guid") sbUrl += guid + "/" return sbUrl
def __init__( self ) : # # Constants # self.DEBUG = False # # Parse parameters... # params = dict(part.split('=') for part in sys.argv[ 2 ][ 1: ].split('&')) self.video_page_url = urllib.unquote_plus( params[ "video_page_url" ] ) # # Settings # self.video_players = { "0" : xbmc.PLAYER_CORE_AUTO, "1" : xbmc.PLAYER_CORE_DVDPLAYER, "2" : xbmc.PLAYER_CORE_MPLAYER } self.video_player = xbmcplugin.getSetting ("video_player") self.english = xbmc.Language (os.getcwd(), "English") self.video_format = xbmcplugin.getSetting ("video_format") self.pref_video_format = (self.english.getLocalizedString(30301), self.english.getLocalizedString(30302), self.english.getLocalizedString(30303)) [int(self.video_format)] # # Play video... # self.playVideo()
def http_request_with_login(url): username = xbmcplugin.getSetting(int(sys.argv[1]), 'username') password = xbmcplugin.getSetting(int(sys.argv[1]), 'password') ADDON_USERDATA_FOLDER = xbmc.translatePath(ADDON.getAddonInfo('profile')) COOKIE_FILE = os.path.join(ADDON_USERDATA_FOLDER, 'cookies') return HTTPInterface.http_get(url, COOKIE_FILE,username, password)
def _fill_media_list( self, categories ): try: ok = True # enumerate through the list of categories and add the item to the media list for ( ltitle, method, userid_required, pq, gq, uq, issearch, thumbnail, authtoken_required, ) in categories: # if a user id is required for category and none supplied, skip category if ( userid_required and self.user_id == "" ): continue if ( authtoken_required and self.authtoken == "" ): continue # set the callback url with all parameters url = '%s?title=%s&category=%s&userid=%s&usernsid=%s&photosetid=""&photoid=""&groupid=""&primary=""&secret=""&server=""&photos=0&page=1&prevpage=0&pq=%s&gq=%s&uq=%s&issearch=%d&update_listing=%d&' % ( sys.argv[ 0 ], quote_plus( repr( ltitle ) ), repr( method ), repr( self.user_id ), repr( self.user_nsid ), quote_plus( repr( pq ) ), quote_plus( repr( gq ) ), quote_plus( repr( uq ) ), issearch, False, ) # check for a valid custom thumbnail for the current method thumbnail = thumbnail or self._get_thumbnail( method ) # set the default icon icon = "DefaultFolder.png" # only need to add label, icon and thumbnail, setInfo() and addSortMethod() takes care of label2 listitem=xbmcgui.ListItem( ltitle, iconImage=icon, thumbnailImage=thumbnail ) # add the item to the media list ok = xbmcplugin.addDirectoryItem( handle=int( sys.argv[ 1 ] ), url=url, listitem=listitem, isFolder=True, totalItems=len( categories ) ) # if user cancels, call raise to exit loop if ( not ok ): raise # we do not want to sort queries list if ( "category='presets_photos'" in sys.argv[ 2 ] or "category='presets_groups'" in sys.argv[ 2 ] or "category='presets_users'" in sys.argv[ 2 ] ): xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE ) # set our plugin category xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=self.args.title ) # set our fanart from user setting if ( xbmcplugin.getSetting( "fanart_image" ) ): xbmcplugin.setPluginFanart( handle=int( sys.argv[ 1 ] ), image=xbmcplugin.getSetting( "fanart_image" ) ) except: # user cancelled dialog or an error occurred print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[ 2 ].tb_frame.f_code.co_name, sys.exc_info()[ 2 ].tb_lineno, sys.exc_info()[ 1 ], ) ok = False return ok
def __init__( self ): computers = int ( xbmcplugin.getSetting("computers") ) + 1 # # List computers... # for i in range(computers) : computer_name = xbmcplugin.getSetting("comp_%u_name" % ( i + 1 )) computer_mac = xbmcplugin.getSetting("comp_%u_mac" % ( i + 1 )) listitem = xbmcgui.ListItem( xbmc.getLocalizedString(30901) % computer_name, iconImage="DefaultProgram.png" ) xbmcplugin.addDirectoryItem( handle = int(sys.argv[ 1] ), url = sys.argv[ 0 ] + '?action=wake&name=%s&mac=%s' % ( computer_name, computer_mac ), listitem=listitem, isFolder=False) # # Disable sorting... # xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE ) # # End of list... # xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def LIBRARY_LIST_TV(): url = common.args.url data = common.getURL(url,useCookie=True) scripts = re.compile(r'<script.*?script>',re.DOTALL) data = scripts.sub('', data) style = re.compile(r'<style.*?style>',re.DOTALL) data = style.sub('', data) tree = BeautifulSoup(data, convertEntities=BeautifulSoup.HTML_ENTITIES) videos = tree.findAll('div',attrs={'class':'lib-item','asin':True}) totalItems = len(videos) for video in videos: xbmcplugin.setContent(int(sys.argv[1]), 'tvshows') asin = video['asin'] name = video.find('',attrs={'class':'title'}).a.string thumb = video.find('img')['src'].replace('._SS160_','') if '[HD]' in name: isHD = True else: isHD = False url = common.BASE_URL+video.find('div',attrs={'class':'title'}).a['href'] #if xbmcplugin.getSetting(pluginhandle,'enablelibrarymeta') == 'true': # asin2,season,episodes,plot,creator,runtime,year,network,actors,genres,stars,votes,HD,TVDBbanner,TVDBposter,TVDBfanart = getShowInfo(url,asin,isHD) # actors = actors.split(',') # infoLabels={'Title': name,'Plot':plot,'year':year,'rating':stars,'votes':votes, # 'Genre':genres,'Season':season,'episode':episodes,'studio':network, # 'duration':runtime,'cast':actors,'TVShowTitle':name,'credits':creator} # if year <> 0: infoLabels['premiered'] = str(year) #else: infoLabels = { 'Title':name} common.addDir(name,'library','LIBRARY_EPISODES',url,thumb,thumb,infoLabels,totalItems) viewenable=xbmcplugin.getSetting(pluginhandle,"viewenable") if viewenable == 'true': view=int(xbmcplugin.getSetting(pluginhandle,"showview")) xbmc.executebuiltin("Container.SetViewMode("+str(confluence_views[view])+")") xbmcplugin.endOfDirectory(pluginhandle)
def http_request_with_login(url): username = xbmcplugin.getSetting(int(sys.argv[1]), 'username') password = xbmcplugin.getSetting(int(sys.argv[1]), 'password') ADDON_USERDATA_FOLDER = xbmc.translatePath(ADDON.getAddonInfo('profile')) COOKIE_FILE = os.path.join(ADDON_USERDATA_FOLDER, 'cookies') return HTTPInterface.http_get(url, COOKIE_FILE, username, password)
def SITE(dur): if xbmcplugin.getSetting("site : GOOGLE") == "true": site = "+site%3Avideo.google.com" GOOGLESEARCH(dur, site) elif xbmcplugin.getSetting("site : YOUTUBE") == "true": site = "+site%3Ayoutube.com" GOOGLESEARCH(dur, site) elif xbmcplugin.getSetting("site : GUBA") == "true": site = "+site%3Aguba.com" GOOGLESEARCH(dur, site) elif xbmcplugin.getSetting("site : YOUKU") == "true": site = "+site%3Ayouku.com" GOOGLESEARCH(dur, site) elif xbmcplugin.getSetting("site : TUDOU") == "true": site = "+site%3Atudou.com" GOOGLESEARCH(dur, site) elif xbmcplugin.getSetting("site : VEOH") == "true": site = "+site%3Aveoh.com" GOOGLESEARCH(dur, site) elif xbmcplugin.getSetting("site : MYSPACE") == "true": site = "+site%3Amyspace.com" GOOGLESEARCH(dur, site) elif xbmcplugin.getSetting("site : DAILYMOTION") == "true": site = "+site%3Adailymotion.com" GOOGLESEARCH(dur, site) elif xbmcplugin.getSetting("site : TRILULILU") == "true": site = "+site%3Atrilulilu.ro" GOOGLESEARCH(dur, site) elif xbmcplugin.getSetting("site : CLIPVN") == "true": site = "+site%3Aclip.vn" GOOGLESEARCH(dur, site) else: site = "" GOOGLESEARCH(dur, site)
def load_acc_details(): last_check = xbmcplugin.getSetting(_handle, "accinfo_lastcheck") info_acc = xbmcplugin.getSetting(_handle, "accinfo_account") user = xbmcplugin.getSetting(_handle, "username") if info_acc != user or (int(time.time()) - int(last_check)) > 15 * 60: # load acc details acc_details = w.getAccountDetails() xbmc.log("waipu accdetails: " + str(acc_details), level=xbmc.LOGDEBUG) if 'error' in acc_details: xbmcaddon.Addon().setSetting('accinfo_status', acc_details["error"]) xbmcaddon.Addon().setSetting('accinfo_account', "-") xbmcaddon.Addon().setSetting('accinfo_subscription', "-") else: xbmcaddon.Addon().setSetting('accinfo_status', "Angemeldet") xbmcaddon.Addon().setSetting('accinfo_account', acc_details["sub"]) xbmcaddon.Addon().setSetting( 'accinfo_subscription', acc_details["userAssets"]["account"]["subscription"]) xbmcaddon.Addon().setSetting('accinfo_lastcheck', str(int(time.time()))) # load network status status = w.getStatus() xbmc.log("waipu status: " + str(status), level=xbmc.LOGDEBUG) xbmcaddon.Addon().setSetting('accinfo_network_ip', status["ip"]) if status["statusCode"] == 200: xbmcaddon.Addon().setSetting('accinfo_network', "Waipu verfügbar") else: xbmcaddon.Addon().setSetting('accinfo_network', status["statusText"])
def openSettings( self ): # is this the first time plugin was run and user has not set email if ( not sys.argv[ 2 ] and xbmcplugin.getSetting( "username" ) == "" and xbmcplugin.getSetting( "runonce" ) == "" ): # set runonce xbmcplugin.setSetting( "runonce", "1" ) # sleep for xbox so dialogs don't clash. (TODO: report this as a bug?) if ( os.environ.get( "OS", "n/a" ) == "xbox" ):
def _get_settings( self ): self.settings = {} self.settings[ "download_mode" ] = int( xbmcplugin.getSetting( "download_mode" ) ) self.settings[ "download_path" ] = xbmcplugin.getSetting( "download_path" ) self.settings[ "use_title" ] = ( xbmcplugin.getSetting( "use_title" ) == "true" ) self.settings[ "username" ] = xbmcplugin.getSetting( "username" ) self.settings[ "password" ] = xbmcplugin.getSetting( "password" )
def play_channel(): title = plugin.args['title'][0] logo_url = plugin.args['logo_url'][0] channel_id = plugin.args['channel_id'][0] stream_resp = w.play_channel(channel_id) xbmc.log("play channel (stream resp): " + str(stream_resp), level=xbmc.LOGDEBUG) art = {'thumb': logo_url, 'icon': logo_url, 'clearlogo': logo_url} metadata = {'title': title, 'mediatype': 'video'} if xbmcplugin.getSetting(plugin.handle, "metadata_on_play") == "true": current_program = w.get_current_program(channel_id) xbmc.log("play channel metadata: " + str(current_program), level=xbmc.LOGDEBUG) b_filter = xbmcplugin.getSetting(plugin.handle, "filter_pictograms") == "true" description = "" if "title" in current_program and current_program["title"] is not None: description = "[B]" + filter_pictograms(current_program["title"], b_filter) + "[/B]\n" metadata.update({ 'title': filter_pictograms(current_program["title"], b_filter) }) if "description" in current_program and current_program[ "description"] is not None: description += filter_pictograms(current_program["description"], b_filter) metadata.update({'plot': description}) return play_inputstream(stream_resp["streamUrl"], metadata, art)
def __init__(self, plugin): if "yupptv" in plugin.path: self.box_id = None self.storage_name = "YTP_COOKIES" self.username = xbmcplugin.getSetting(plugin.handle, "username") self.password = xbmcplugin.getSetting(plugin.handle, "password") if self.username == "" or self.password == "": xbmcgui.Dialog().ok( "YuppTV warning", "You have to use your Yupptv account to connect. Goto addons setting", ) self.sess = requests.session() self.sess.headers.update({ "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" }) stored_cookies = self.get_data_from_storage(self.storage_name) print("#### SORED") print(stored_cookies) if stored_cookies: self.sess.cookies = stored_cookies if not self.sess.cookies.get("BoxId"): self.login() else: pass
def login(self, auth_type): if auth_type == "Normal Lynda.com Account": username = xbmcplugin.getSetting(__handle__, "username") password = xbmcplugin.getSetting(__handle__, "password") login_success = self.api.login_normal(username, password) if not login_success: xbmcgui.Dialog().ok(addonname, "Could not login.", "Please check your credentials are correct.") elif auth_type == 'Organisation': login_token = util.load_text(addon, self.TOKEN_USER_INPUT) # Can be None if file doesn't exist if login_token: login_token = login_token.strip() print("got login token", login_token) self.api.set_token(login_token) user = self.api.user() if not user: xbmcgui.Dialog().ok(addonname, "Could not login.", "Please make sure you have a valid login token in the user_login_token file in the addon data directory") else: xbmcgui.Dialog().ok(addonname, "Could not login.", "Please make sure you have the user_login_token file with your login token in the addon data directory") elif auth_type == 'IP Site License': login_success = self.api.login_ip() if not login_success: xbmcgui.Dialog().ok(addonname, "Could not login.", "Your IP may not have a site license.")
def playRTMP(): vid=re.compile('id=(\d+)').findall(common.args.url)[0] smilurl = getsmil(vid) rtmpurl = str(getrtmp()) swfUrl = getswfUrl() link = str(common.getHTML(smilurl)) match=re.compile('<video src="(.+?)"').findall(link) if (common.settings['quality'] == '0'): dia = xbmcgui.Dialog() ret = dia.select(xbmc.getLocalizedString(30004), [xbmc.getLocalizedString(30016),xbmc.getLocalizedString(30017),xbmc.getLocalizedString(30018)]) if (ret == 2): return else: ret = None for playpath in match: playpath = playpath.replace('.flv','') if '_0700' in playpath and (xbmcplugin.getSetting("quality") == '1' or '_0700' in playpath and (ret == 0)): item=xbmcgui.ListItem(common.args.name, iconImage='', thumbnailImage='') item.setInfo( type="Video",infoLabels={ "Title": common.args.name}) item.setProperty("SWFPlayer", swfUrl) item.setProperty("PlayPath", playpath) elif '_0500' in playpath and (xbmcplugin.getSetting("quality") == '2') or '_0500' in playpath and (ret == 1): item=xbmcgui.ListItem(common.args.name, iconImage='', thumbnailImage='') item.setInfo( type="Video",infoLabels={ "Title": common.args.name}) item.setProperty("SWFPlayer", swfUrl) item.setProperty("PlayPath", playpath) xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(rtmpurl, item)
def gethighurl(code): xbmc.output("[megavideo.py] Usa modo premium") code = getcode(code) megavideocookie = xbmcplugin.getSetting("megavideocookie") xbmc.output("[megavideo.py] megavideocookie=#"+megavideocookie+"#") #if megavideocookie=="": xbmc.output("[megavideo.py] Averiguando cookie...") megavideologin = xbmcplugin.getSetting("megavideouser") xbmc.output("[megavideo.py] megavideouser=#"+megavideologin+"#") megavideopassword = xbmcplugin.getSetting("megavideopassword") xbmc.output("[megavideo.py] megavideopassword=#"+megavideopassword+"#") megavideocookie = GetMegavideoUser(megavideologin, megavideopassword) xbmc.output("[megavideo.py] megavideocookie=#"+megavideocookie+"#") #xbmcplugin.setSetting("megavideocookie",megavideocookie) req = urllib2.Request("http://www.megavideo.com/xml/player_login.php?u="+megavideocookie+"&v="+code) req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3') response = urllib2.urlopen(req) data=response.read() response.close() # saca los enlaces patronvideos = 'downloadurl="([^"]+)"' matches = re.compile(patronvideos,re.DOTALL).findall(data) movielink = matches[0] movielink = movielink.replace("%3A",":") movielink = movielink.replace("%2F","/") movielink = movielink.replace("%20"," ") return movielink
def _checkSettings(): # check mandatory settings are set self.email = xbmcplugin.getSetting("user_email") self.password = xbmcplugin.getSetting("user_password") ok = bool(self.email and self.password) log(" _checkSettings() ok=%s" % ok) return ok
def _checkSettings(): # check mandatory settings are set self.email = xbmcplugin.getSetting( "user_email" ) self.password = xbmcplugin.getSetting( "user_password" ) ok = bool( self.email and self.password ) log(" _checkSettings() ok=%s" % ok) return ok
def __init__(self): self._parse_argv() # parse sys.argv if not self.loadSettings(): return if (not sys.argv[2]): # cleanup for new start deleteFile(self.TAGS_FILENAME) deleteFile(self.SUBS_FILENAME) files = os.listdir(TEMP_DIR) for f in files: if f.startswith(__plugin__ + "_items_"): deleteFile(os.path.join(TEMP_DIR, f)) self.client = grc.GoogleReaderClient() if not self.authenticate(): # authenticate user return ok = self.get_categories() else: # not first run # load saved google authkey SID = xbmcplugin.getSetting("authkey") log("loaded SID=%s" % SID) # create client with known key self.client = grc.GoogleReaderClient(SID, \ pagesize=xbmcplugin.getSetting( "pagesize" ), \ show_read=bool(xbmcplugin.getSetting( "show_read" ) == "true")) exec "ok = self.%s()" % (self.args.category, ) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
def getUserState(): userState = 'free' # user data login = xbmcplugin.getSetting(HANDLE, 'email') pw = xbmcplugin.getSetting(HANDLE, 'pass') if (len(login) != 0): loginURL = 'https://www.schoener-fernsehen.com/ajax/login.php' params = dict() params["email"] = login params["password"] = pw r = requests.post(loginURL, data=params) result = r.text obj = json.loads(result) state = obj['success'] if (state): userState = obj['membership'] xbmc.log('SF: userstate ' + userState) else: userState = 'error' xbmc.log('SF: login failed') return userState
def showCredit(): if __debug: xbmc.log('- credit -') # user data login = xbmcplugin.getSetting(_handle, 'email') password = xbmcplugin.getSetting(_handle, 'pass') data = website.login(login, password, __cookiePath) # to do checks if (data.state == 'Premium'): xbmcgui.Dialog().ok( 'otrstream', __addon.getLocalizedString(30040) + ' ' + xbmcplugin.getSetting(_handle, 'email'), __addon.getLocalizedString(30041) + ' ' + data.state + ' - ' + data.decode, __addon.getLocalizedString(30042) + ' ' + data.value) else: xbmcgui.Dialog().ok( 'otrstream', __addon.getLocalizedString(30040) + ' ' + xbmcplugin.getSetting(_handle, 'email'), __addon.getLocalizedString(30041) + ' ' + data.state + ' - ' + data.decode, __addon.getLocalizedString(30042) + ' ' + data.value)
def SEARCH(dur): keyb = xbmc.Keyboard('', 'Search Veoh') keyb.doModal() if (keyb.isConfirmed()): search = keyb.getText() encode=urllib.quote_plus(search) if xbmcplugin.getSetting("Open Veoh Search") == "true": url='http://www.veoh.com/rest/v2/execute.xml?method=veoh.search.video&userQuery='+encode+'&contentSource=veoh'+dur+'&safe=false&maxResults=100&apiKey=08344E97-13CE-E0BE-28AA-B8F7D686DD07' f = open(os.getcwd().replace(";","")+'/search.veoh', 'a');f.write('<URL>'+url+'</URL><NAME>'+search+'</NAME>');f.close() elif xbmcplugin.getSetting("Specific Veoh Search") == "true": url='http://www.veoh.com/rest/v2/execute.xml?method=veoh.search.video&userQuery="'+encode+'"&contentSource=veoh'+dur+'&safe=false&maxResults=100&apiKey=08344E97-13CE-E0BE-28AA-B8F7D686DD07' f = open(os.getcwd().replace(";","")+'/search.veoh', 'a');f.write('<URL>'+url+'</URL><NAME>'+search+'</NAME>');f.close() else: url='http://www.veoh.com/rest/v2/execute.xml?method=veoh.search.video&userQuery="'+encode+'"&contentSource=veoh'+dur+'&safe=false&maxResults=100&apiKey=08344E97-13CE-E0BE-28AA-B8F7D686DD07' req = urllib2.Request(url) req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14') response = urllib2.urlopen(req) link=response.read() response.close() lastresult=re.compile('items="(.+?)"').findall(link);last=int(lastresult[0]) perma=re.compile('permalinkId="(.+?)"').findall(link) length=re.compile('length="(.+?)"').findall(link) purl=re.compile('fullPreviewHashPath="(.+?)"').findall(link) thumbnail=re.compile('fullHighResImagePath="(.+?)"').findall(link) name=re.compile('\r\n\ttitle="(.+?)"\r\n\tdateAdded=".+?"').findall(link) ipod=re.compile('ipodUrl="(.+?)"').findall(link) for i in range(0,len(perma)): addLink('%s Dur: %s '%(name[i],length[i]),purl[i],thumbnail[i]) addDir('%s - FULL MP4'%name[i],ipod[i],4,'') if last>100: addDir(" NEXT PAGE",'http://www.veoh.com/rest/v2/execute.xml?method=veoh.search.video&userQuery="'+encode+'"&contentSource=veoh'+dur+'&offset=100&safe=false&maxResults=100&apiKey=08344E97-13CE-E0BE-28AA-B8F7D686DD07',3,"") else: pass
def load_page(url, proxy=False, getRedirect=False): print url if proxy == True: proxy = False proxy_address = xbmcplugin.getSetting(thisPlugin,'proxy_address') proxy_port = xbmcplugin.getSetting(thisPlugin,'proxy_port') if len(proxy_address): proxy = True us_proxy = "http://"+proxy_address+":"+proxy_port print 'Using proxy: ' + us_proxy proxy_handler = urllib2.ProxyHandler({'http':us_proxy}) opener = urllib2.build_opener(proxy_handler, RTMPHandler) if not proxy: opener = urllib2.build_opener(RTMPHandler) urllib2.install_opener(opener) req = urllib2.Request(url) req.add_header('Accept-encoding', 'gzip') response = urllib2.urlopen(req) if getRedirect: return response.geturl() if response.info().get('Content-Encoding') == 'gzip': buf = StringIO( response.read()) f = gzip.GzipFile(fileobj=buf) link = f.read() else: link = response.read() response.close() return link
def PLAY_CHANNEL(url, name): #2 req = urllib2.Request(url) req.add_header( 'User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3' ) response = opener.open(req) link = response.read() response.close() # print link match_streams = re.compile('<center>(.+?)</center>', re.DOTALL).findall(link) match_stream = re.compile("'(.+?)'", re.DOTALL).findall(match_streams[0]) if xbmcplugin.getSetting(pluginhandle, "quality") == '2': stream = match_stream[2] elif xbmcplugin.getSetting(pluginhandle, "quality") == '1': stream = match_stream[1] elif xbmcplugin.getSetting(pluginhandle, "quality") == '0': stream = match_stream[0] item = xbmcgui.ListItem(path=stream) return xbmcplugin.setResolvedUrl(pluginhandle, True, item)
def performCredentialCheck(): username = xbmcplugin.getSetting(plugin.handle, 'username') password = xbmcplugin.getSetting(plugin.handle, 'password') if not username or not password: registration_notice = xbmcgui.Dialog() registration_notice.ok( 'VOYO účet', 'Pro přehrávání pořadů je potřeba účet s aktivním předplatným na voyo.nova.cz\n\nPokud účet ještě nemáte, zaregistrujte se na voyo.nova.cz, předplaťte účet na měsíc nebo rok a v dalším okně vyplňte přihlašovací údaje.' ) username_prompt = xbmcgui.Dialog() usr = username_prompt.input('Uživatel (e-mail)') if not usr: return False _addon.setSetting(id='username', value=usr) password_prompt = xbmcgui.Dialog() pswd = password_prompt.input('Heslo', option=xbmcgui.ALPHANUM_HIDE_INPUT) if not pswd: return False _addon.setSetting(id='password', value=pswd) return True
def _get_user( self ): try: self.user_id = "" self.user_nsid = "" # if this is first run open settings and authorize self._run_once() # get the users id and token userid = xbmcplugin.getSetting( "user_id" ) self.authtoken = xbmcplugin.getSetting( "authtoken" ) # if user did not edit settings, return if ( userid == "" ): return True # flickr client client = FlickrClient( True ) # find the user Id of the person if ( "@" in userid ): user = client.flickr_people_findByEmail( find_email=userid ) else: user = client.flickr_people_findByUsername( username=userid ) # if user id is valid and no error occurred return True ok = user[ "stat" ] != "fail" # if successful, set our user id and nsid if ( ok ): self.user_id = user[ "user" ][ "id" ] self.user_nsid = user[ "user" ][ "nsid" ] except: # oops print error message print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[ 2 ].tb_frame.f_code.co_name, sys.exc_info()[ 2 ].tb_lineno, sys.exc_info()[ 1 ], ) ok = False # if an error or an invalid id was entered, notify the user if ( not ok ): xbmcgui.Dialog().ok( xbmc.getLocalizedString( 30900 ), xbmc.getLocalizedString( 30901 ), xbmc.getLocalizedString( 30902 ) ) return ok
def _get_settings(self): self.settings = {} self.settings["country"] = int(xbmcplugin.getSetting("country")) self.settings["quality"] = int(xbmcplugin.getSetting("quality")) self.settings["include_wmv"] = xbmcplugin.getSetting( "include_wmv") == "true" self.settings["mode"] = int(xbmcplugin.getSetting("mode"))
def __init__(self): self.settings = xbmcaddon.Addon(id='plugin.video.mediathek') self.quality = int(xbmcplugin.getSetting(int(sys.argv[1]), "quality")) self.preferedStreamTyp = int( xbmcplugin.getSetting(int(sys.argv[1]), "preferedStreamType")) self.log("quality: %s" % (self.quality))
def play(_handle, _addon, params): channel = params['channel'] if not channel in CHANNELS: raise #TODO parse_playlist = xbmcplugin.getSetting(_handle, 'retroparse') == 'true' alternative = xbmcplugin.getSetting(_handle, 'retroalt') == 'true' channel = ALTERNATIVE[channel] if alternative and channel in ALTERNATIVE else CHANNELS[channel] if parse_playlist: best = None streams = m3u8.load(channel['path'] + channel['playlist'], headers=HEADERS) for stream in streams.playlists: if best is None: best = stream else: if stream.stream_info.bandwidth > best.stream_info.bandwidth: best = stream li = xbmcgui.ListItem(path=channel['path']+best.uri+'|'+urlencode(HEADERS)) xbmcplugin.setResolvedUrl(_handle, True, li) else: li = xbmcgui.ListItem(path=channel['path']+channel['playlist']+'|'+urlencode(HEADERS)) li.setProperty('inputstreamaddon','inputstream.adaptive') #kodi 18 li.setProperty('inputstream','inputstream.adaptive') #kodi 19 li.setProperty('inputstream.adaptive.manifest_type','hls') xbmcplugin.setResolvedUrl(_handle, True, li)
def _play_video(self): # Youtube client client = YoutubeClient(authkey=xbmcplugin.getSetting("authkey")) # construct the video url with session id and get video details url, title, director, genre, rating, runtime, count, date, thumbnail, plotoutline, video_id = client.construct_video_url( self.args.video_url, ( 18, 22, )[xbmcplugin.getSetting("hd_videos") == "true"]) # get cached thumbnail, no need to redownload thumbnail = xbmc.getCacheThumbName(sys.argv[0] + sys.argv[2]) thumbnail = os.path.join(xbmc.translatePath("special://profile"), "Thumbnails", "Video", thumbnail[0], thumbnail) # construct our listitem listitem = xbmcgui.ListItem(title, thumbnailImage=thumbnail, path=url) # set the key information listitem.setInfo( "video", { "Title": title, "Plotoutline": plotoutline, "Plot": plotoutline, "Director": director, "Genre": genre, "Rating": rating, "Date": date }) # Resolve url xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
def getHTML(url, enableproxy=False): try: if enableproxy == True: us_proxy = ( "http://" + xbmcplugin.getSetting(pluginhandle, "us_proxy") + ":" + xbmcplugin.getSetting(pluginhandle, "us_proxy_port") ) print "Using proxy: " + us_proxy proxy_handler = urllib2.ProxyHandler({"http": us_proxy}) opener = urllib2.build_opener(proxy_handler) urllib2.install_opener(opener) print "CBS --> common :: getHTML :: url = " + url req = urllib2.Request(url) req.add_header( "User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3" ) response = urllib2.urlopen(req) link = response.read() response.close() except urllib2.URLError, e: print "Error reason: ", e.reason return False
def __init__( self ): self._parse_argv() # parse sys.argv if not self.loadSettings(): return if ( not sys.argv[ 2 ] ): # cleanup for new start deleteFile(self.TAGS_FILENAME) deleteFile(self.SUBS_FILENAME) files = os.listdir(TEMP_DIR) for f in files: if f.startswith(__plugin__+"_items_"): deleteFile(os.path.join(TEMP_DIR, f)) self.client = grc.GoogleReaderClient() if not self.authenticate(): # authenticate user return ok = self.get_categories( ) else: # not first run # load saved google authkey SID = xbmcplugin.getSetting( "authkey" ) log("loaded SID=%s" % SID) # create client with known key self.client = grc.GoogleReaderClient(SID, \ pagesize=xbmcplugin.getSetting( "pagesize" ), \ show_read=bool(xbmcplugin.getSetting( "show_read" ) == "true")) exec "ok = self.%s()" % ( self.args.category, ) xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=ok)
def playRTMP(): vid=re.compile('id=(\d+)').findall(common.args.url)[0] smilurl = getsmil(vid) rtmpurl = str(getrtmp()) swfUrl = getswfUrl() link = str(common.getHTML(smilurl)) match=re.compile('<video src="(.+?)"').findall(link) if (common.settings['quality'] == '0'): dia = xbmcgui.Dialog() ret = dia.select(xbmc.getLocalizedString(30004), [xbmc.getLocalizedString(30016),xbmc.getLocalizedString(30017),xbmc.getLocalizedString(30018)]) if (ret == 2): return else: ret = None for playpath in match: playpath = playpath.replace('.flv','') if '_0700' in playpath and (xbmcplugin.getSetting(pluginhandle,"quality") == '1' or '_0700' in playpath and (ret == 0)): item=xbmcgui.ListItem(common.args.name, iconImage='', thumbnailImage='') item.setInfo( type="Video",infoLabels={ "Title": common.args.name}) item.setProperty("SWFPlayer", swfUrl) item.setProperty("PlayPath", playpath) elif '_0500' in playpath and (xbmcplugin.getSetting(pluginhandle,"quality") == '2') or '_0500' in playpath and (ret == 1): item=xbmcgui.ListItem(common.args.name, iconImage='', thumbnailImage='') item.setInfo( type="Video",infoLabels={ "Title": common.args.name}) item.setProperty("SWFPlayer", swfUrl) item.setProperty("PlayPath", playpath) xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(rtmpurl, item)
def performCredentialCheck(): username = xbmcplugin.getSetting(plugin.handle, 'username') password = xbmcplugin.getSetting(plugin.handle, 'password') if not username or not password: registration_notice = xbmcgui.Dialog() registration_notice.ok( 'Nutné přihlášení', 'Pro přehrávání pořadů je nyní potřeba účet na iPrima.cz\n\nPokud účet ještě nemáte, zaregistrujte se na auth.iprima.cz/user/register a v dalším okně vyplňte přihlašovací údaje.' ) username_prompt = xbmcgui.Dialog() usr = username_prompt.input('Uživatel (e-mail)') if not usr: return False addon.setSetting(id='username', value=usr) password_prompt = xbmcgui.Dialog() pswd = password_prompt.input('Heslo', option=xbmcgui.ALPHANUM_HIDE_INPUT) if not pswd: return False addon.setSetting(id='password', value=pswd) return True
def createDate(): ##core module archiveMonth = xbmcplugin.getSetting('archiveMonth') archiveDay = xbmcplugin.getSetting('archiveDay') archiveYear = xbmcplugin.getSetting('archiveYear') archiveMonth = str(int(archiveMonth)+1) archiveDay = str(int(archiveDay)+1) if len(archiveMonth) == 1: archiveMonth = '0' + str(archiveMonth) elif len(archiveMonth) == 2: archiveMonth = archiveMonth if len(archiveDay) == 1: archiveDay = '0' + str(archiveDay) elif len(archiveMonth) == 2: archiveDay = str(archiveDay) if archiveYear == int('0') or '0': archiveYear = '2009' elif archiveYear == int('1') or '1': archiveYear = '2010' archiveDate = '/' + archiveMonth + '-' + archiveDay + '-' + archiveYear + '/' return archiveDate
def load_page(url, proxy=False, getRedirect=False): print url if proxy == True: proxy = False proxy_address = xbmcplugin.getSetting(thisPlugin, 'proxy_address') proxy_port = xbmcplugin.getSetting(thisPlugin, 'proxy_port') if len(proxy_address): proxy = True us_proxy = "http://" + proxy_address + ":" + proxy_port print 'Using proxy: ' + us_proxy proxy_handler = urllib2.ProxyHandler({'http': us_proxy}) opener = urllib2.build_opener(proxy_handler, RTMPHandler) if not proxy: opener = urllib2.build_opener(RTMPHandler) urllib2.install_opener(opener) req = urllib2.Request(url) req.add_header('Accept-encoding', 'gzip') response = urllib2.urlopen(req) if getRedirect: return response.geturl() if response.info().get('Content-Encoding') == 'gzip': buf = StringIO(response.read()) f = gzip.GzipFile(fileobj=buf) link = f.read() else: link = response.read() response.close() return link
def getPage(url, showMessage = True, cookies = False): global cookieJar if(showMessage): handle = int(sys.argv[1]) username=xbmcplugin.getSetting(handle, 'username') password=xbmcplugin.getSetting(handle, 'password') logged = login(username, password) if logged is not None: url = url+login try: req = urllib2.Request(url) req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0') if(cookies == True): req.add_header('Cookie', cookieJar) response = urllib2.urlopen(req) if(cookies == True): cookieJar = response.info().getheader('Set-Cookie') if response.info().get('Content-Encoding') == 'gzip': buf = StringIO( response.read()) f = gzip.GzipFile(fileobj=buf) data = f.read() else: data = response.read() response.close() return data except urllib2.URLError, e: if showMessage: line1 = "Fehler!" line2 = "bs.to nicht erreichbar" xbmcgui.Dialog().ok(line1, line2) sys.exit() return ""
def searchStation(): if __debug: xbmc.log('- search station -') # user data login = xbmcplugin.getSetting(_handle, 'email') password = xbmcplugin.getSetting(_handle, 'pass') keyboard = xbmc.Keyboard('', __addon.getLocalizedString(30031)) keyboard.doModal() if (keyboard.isConfirmed()): keyword = keyboard.getText() station = '' date = '' keyboard = xbmc.Keyboard('', __addon.getLocalizedString(30036)) keyboard.doModal() if (keyboard.isConfirmed()): station = keyboard.getText() now = datetime.strftime(datetime.now(), '%d.%m') # %y') keyboard = xbmc.Keyboard(now, __addon.getLocalizedString(30038)) keyboard.doModal() if (keyboard.isConfirmed()): date = keyboard.getText() if len(keyword) > 0: xbmcplugin.setContent(_handle, 'movies') #addPictureItem(__addon.getLocalizedString(30020), _url + '?station=' + station + '&page=2&keyword=' + keyword, 'DefaultFolder.png') de = xbmcplugin.getSetting(_handle, 'searchDE') == "true" hList = website.searchStation(login, password, __cookiePath, keyword, station, date, '1') for aItem in hList: id = aItem.id title = aItem.title if len(aItem.serie) > 0: desc = aItem.date + " " + aItem.time + " " + aItem.serie + "-" + aItem.episode + " " + aItem.desc else: desc = aItem.date + " " + aItem.time + " " + aItem.desc thumb = aItem.thumb addPictureItem3( title, _url + '?categories=%s' % id + '&title=%s' % title, thumb, desc, aItem.genre) if (__view): xbmc.executebuiltin('Container.SetViewMode(%d)' % MediaListView3) xbmcplugin.endOfDirectory(_handle)
def SITE(dur): if xbmcplugin.getSetting("site : GOOGLE") == "true": site="+site%3Avideo.google.com" GOOGLESEARCH(dur,site) elif xbmcplugin.getSetting("site : YOUTUBE") == "true": site="+site%3Ayoutube.com" GOOGLESEARCH(dur,site) elif xbmcplugin.getSetting("site : GUBA") == "true": site="+site%3Aguba.com" GOOGLESEARCH(dur,site) elif xbmcplugin.getSetting("site : YOUKU") == "true": site="+site%3Ayouku.com" GOOGLESEARCH(dur,site) elif xbmcplugin.getSetting("site : TUDOU") == "true": site="+site%3Atudou.com" GOOGLESEARCH(dur,site) elif xbmcplugin.getSetting("site : VEOH") == "true": site="+site%3Aveoh.com" GOOGLESEARCH(dur,site) elif xbmcplugin.getSetting("site : MYSPACE") == "true": site="+site%3Amyspace.com" GOOGLESEARCH(dur,site) elif xbmcplugin.getSetting("site : DAILYMOTION") == "true": site="+site%3Adailymotion.com" GOOGLESEARCH(dur,site) elif xbmcplugin.getSetting("site : TRILULILU") == "true": site="+site%3Atrilulilu.ro" GOOGLESEARCH(dur,site) elif xbmcplugin.getSetting("site : CLIPVN") == "true": site="+site%3Aclip.vn" GOOGLESEARCH(dur,site) else: site="" GOOGLESEARCH(dur,site)
def download_button(url,name): print url req = urllib2.Request(url) req.add_header('User-Agent', HEADER) f=urllib2.urlopen(req) a=f.read() f.close() p=re.compile('<param name="movie" value="http://www.traileraddict.com/emb/(.+?)">') info=p.findall(a) url='http://www.traileraddict.com/fvar.php?tid='+info[0] #print url req = urllib2.Request(url) req.add_header('User-Agent', HEADER) f=urllib2.urlopen(req) a=f.read() f.close() p=re.compile('fileurl=(.+?)&vidwidth') info=p.findall(a) z=re.compile('&image=(.+?)').findall(a) url=info[0] thumb=z[0] #print thumb #print url title=name name=clean_file(name) name=name[:+32] if (xbmcplugin.getSetting('ask_filename') == 'true'): searchStr = name keyboard = xbmc.Keyboard(searchStr, "Save as:") keyboard.doModal() if (keyboard.isConfirmed() == False): return searchstring = keyboard.getText() name=searchstring def Download(url,dest): dp = xbmcgui.DialogProgress() dp.create('Downloading',title,'Filename: '+name+ '.flv') urllib.urlretrieve(url,dest,lambda nb, bs, fs, url=url: _pbhook(nb,bs,fs,url,dp)) def _pbhook(numblocks, blocksize, filesize, url=None,dp=None): try: percent = min((numblocks*blocksize*100)/filesize, 100) dp.update(percent) except: percent = 100 dp.update(percent) if dp.iscanceled(): dp.close() flv_file = xbmc.translatePath(os.path.join(xbmcplugin.getSetting('download_Path'), name + '.flv' )) Download(url,flv_file) if xbmcplugin.getSetting("dvdplayer") == "true": player_type = xbmc.PLAYER_CORE_DVDPLAYER else: player_type = xbmc.PLAYER_CORE_MPLAYER g_thumbnail = xbmc.getInfoImage( "ListItem.Thumb" ) listitem=xbmcgui.ListItem(title ,iconImage="DefaultVideo.png", thumbnailImage=g_thumbnail) if (os.path.isfile(flv_file)): dia = xbmcgui.Dialog() if dia.yesno('Download Complete', 'Do you want to play this video?'): xbmc.Player(player_type).play(flv_file, listitem)
def CATS(): if xbmcplugin.getSetting("Clear Previous Searches") == "true": os.remove(os.getcwd().replace(";","")+'/search.veoh') else: user=xbmcplugin.getSetting("Set User name: ") addDir('USER SUBSCRIPTIONS','http://www.veoh.com/rest/v2/execute.xml?method=veoh.people.getSubscriptions&username='******'&maxResults=100&apiKey=5697781E-1C60-663B-FFD8-9B49D2B56D36',3,'') addDir('USER FAVOURITES','http://www.veoh.com/rest/v2/execute.xml?method=veoh.people.getFavorites&username='******'&maxResults=100&safe=false&apiKey=5697781E-1C60-663B-FFD8-9B49D2B56D36',3,'') addDir("SEARCH VEOH","http://Voinage.com",1,"");addDir("PREVIOUS SEARCHES","http://Voinage.com",2,"")
def __init__(self,settings): self.settings = xbmcaddon.Addon(id='plugin.video.mediathek'); self.quality = int(xbmcplugin.getSetting(int(sys.argv[1]), "quality" )); self.preferedStreamTyp = int(xbmcplugin.getSetting(int(sys.argv[1]), "preferedStreamType")); self.log("quality: %s"%(self.quality)); self.plugin_profile_dir = xbmc.translatePath(settings.getAddonInfo("profile")) if not os.path.exists(self.plugin_profile_dir): os.mkdir(self.plugin_profile_dir);
def VIDEOLINKS(url, name): items = getHTML(url) try: configurl = re.compile('\("CONFIG_URL", (.+?)\);').findall(items)[0] except: configurl = re.compile( '<param name="flashvars" value="CONFIG_URL=(.+?)"').findall( items)[0] configurl = configurl.replace('"', '') print 'CONFIG_URL:\t' + str(configurl) url = baseurl + configurl.replace('%26', '&') configxml = getHTML(url) mrssurl = re.compile('<feed>(.+?)</feed>').findall(configxml, re.DOTALL) if 'endOfPlayRelatedList' in mrssurl[0]: mrssurl = mrssurl[1] else: mrssurl = mrssurl[0] mrssurl = mrssurl.replace('&', '&') ifilmid = re.compile('ifilmId=(.+?)\&').findall(mrssurl) mrssxml = getHTML(mrssurl) match = re.compile( "<media:content type='text/xml' medium='video' isDefault='true' duration='(.+?)' url='(.+?)'" ).findall(mrssxml) stacked_url = 'stack://' for param, guid in match: items = getHTML(guid) videos = re.compile('<src>(.+?)</src>').findall(items, re.DOTALL) print len(videos) if len(videos) == 1: for link in videos: link = link.replace('&', '&') stacked_url += link.replace(',', ',,') + ' , ' else: segments = [] for link in videos: link = link.replace('&', '&') if '_1200.flv' in link and (xbmcplugin.getSetting( pluginhandle, "quality") == '0'): segments.append(link) elif '_700.flv' in link and (xbmcplugin.getSetting( pluginhandle, "quality") == '1'): segments.append(link) elif '_300.flv' in link and (xbmcplugin.getSetting( pluginhandle, "quality") == '2'): segments.append(link) for url in segments: swfUrl = "http://media.mtvnservices.com/player/release/?v=4.5.3" rtmpurl = url + " swfurl=" + swfUrl + " swfvfy=true" stacked_url += rtmpurl.replace(',', ',,') + ' , ' stacked_url = stacked_url[:-3] print 'FINAL URL' print stacked_url item = xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage='', path=stacked_url) item.setInfo(type="Video", infoLabels={"Title": name}) xbmcplugin.setResolvedUrl(pluginhandle, True, item)
def _get_settings( self ): self.settings = {} self.settings[ "username" ] = xbmcplugin.getSetting( "username" ) self.settings[ "include_racy" ] = ( "exclude", "include", )[ xbmcplugin.getSetting( "include_racy" ) == "true" ] self.settings[ "perpage" ] = ( 10, 15, 20, 25, 30, 40, 50, 75, 100, )[ int( xbmcplugin.getSetting( "perpage" ) ) ] self.settings[ "feed_time" ] = ( "all_time", "today", "this_week", "this_month", )[ int( xbmcplugin.getSetting( "feed_time" ) ) ] self.settings[ "region_id" ] = ( "", "AU", "BR", "CA", "FR", "DE", "GB", "NL", "HK", "IE", "IT", "JP", "MX", "NZ", "PL", "RU", "KR", "ES", "TW", "US", )[ int( xbmcplugin.getSetting( "region_id" ) ) ] self.settings[ "saved_searches" ] = ( 10, 20, 30, 40, )[ int( xbmcplugin.getSetting( "saved_searches" ) ) ] self.settings[ "download_path" ] = xbmcplugin.getSetting( "download_path" )
def get_settings(): settings = {} try: settings['path'] = xbmcplugin.getSetting( 'path' ) settings['EyetvTOG'] = xbmcplugin.getSetting( 'EyetvTOG' ) return settings except: print "couldn't load settings" pass
def get_settings(): settings = {} try: settings['path'] = xbmcplugin.getSetting('path') settings['EyetvTOG'] = xbmcplugin.getSetting('EyetvTOG') return settings except: print "couldn't load settings" pass
def _load_settings(self): self._rss_video_feed = xbmcplugin.getSetting(self._plugin_id, "rss_video_feed") self._rss_audio_feed = xbmcplugin.getSetting(self._plugin_id, "rss_audio_feed") self._regex_folge = r"%s" % xbmcplugin.getSetting( self._plugin_id, "regex_folge") self._regex_thema = r"%s" % xbmcplugin.getSetting( self._plugin_id, "regex_thema")
def play_recording(): streaming_data = w.play_recording(plugin.args['recording_id'][0]) xbmc.log("play recording: " + str(streaming_data), level=xbmc.LOGDEBUG) for stream in streaming_data["streamingDetails"]["streams"]: if stream["protocol"] == 'MPEG_DASH': path = stream["href"] if path: path = path + "|User-Agent=" + user_agent # print(path) break b_filter = xbmcplugin.getSetting(plugin.handle, "filter_pictograms") == "true" b_episodeid = xbmcplugin.getSetting(plugin.handle, "recordings_episode_id") == "true" b_recordingdate = xbmcplugin.getSetting(plugin.handle, "recordings_date") == "true" title = "" metadata = {'mediatype': 'video'} if streaming_data["epgData"]["title"]: metadata['title'] = filter_pictograms( streaming_data["epgData"]["title"], b_filter) if streaming_data["epgData"]["episodeTitle"]: title = title + ": " + filter_pictograms( streaming_data["epgData"]["episodeTitle"], b_filter) if b_recordingdate and not streaming_data["epgData"][ "episodeId"] and streaming_data["epgData"]["startTime"]: start_date = parser.parse(streaming_data['epgData']['startTime']) title = title + " " + start_date.strftime("(%d.%m.%Y %H:%M)") if b_episodeid and streaming_data['epgData']['season'] and streaming_data[ 'epgData']['episode']: title = title + " (S" + streaming_data['epgData'][ 'season'] + "E" + streaming_data['epgData']['episode'] + ")" metadata.update({ 'season': streaming_data['epgData']['season'], 'episode': streaming_data['epgData']['episode'], }) metadata.update({"title": title}) if "epgData" in streaming_data and streaming_data["epgData"]["description"]: metadata.update({ "plot": filter_pictograms(streaming_data["epgData"]["description"], b_filter) }) art = dict() if "epgData" in streaming_data and len( streaming_data["epgData"]["previewImages"]) > 0: logo_url = streaming_data["epgData"]["previewImages"][ 0] + "?width=256&height=256" art = {'thumb': logo_url, 'icon': logo_url} return play_inputstream(path, metadata, art)
def showRootMenu(): # Log in mail = xbmcplugin.getSetting(pluginhandle, 'mail') password = xbmcplugin.getSetting(pluginhandle, 'password') session = {} postObject = {} postObject['session'] = session if (mail is not None) and (len(mail) > 0) and (password is not None) and ( len(password) > 0): session['email'] = mail session['password'] = password else: cookieJar.clear() jsonObject = getJsonObject(baseurl + '/api/session.json', postObject) receivedSession = jsonObject['session'] authenticityToken = receivedSession['csrf_token'] userId = receivedSession['user_id'] # Veequalizer if userId is not None: addDir('Veequalizer', '', MODE_VEEQUALIZER, getThumbUrl(0), authenticityToken) # Get standard channels jsonObject = getJsonObject( baseurl + '/ws.json?method=Channel.allWithClips&streaming_method=' + streamingMethod) for object in jsonObject: channel = object['channel'] title = channel['title'] identifier = channel['id'] thumb = getThumbUrl(identifier) url = baseurl + '/ws.json?method=Channel.clips&channelId=' + str( identifier) + '&streaming_method=' + streamingMethod description = channel['channel_info'] shortDescription = channel['channel_message'] additionalInfos = {} additionalInfos['plot'] = description additionalInfos['plotoutline'] = shortDescription liz = addLink(title, url, MODE_PLAY, thumb, authenticityToken, additionalInfos=additionalInfos) xbmcplugin.endOfDirectory(int(sys.argv[1]))
def _download_video(self): try: # Youtube client client = YoutubeClient(authkey=xbmcplugin.getSetting("authkey")) # construct the video url with session id and get video details url, self.g_title, self.g_director, self.g_genre, self.g_rating, self.g_runtime, self.g_count, self.g_date, self.g_thumbnail, self.g_plotoutline, video_id = client.construct_video_url( self.args.video_url, (18, 22)[xbmcplugin.getSetting("hd_videos") == "true"] ) # create our temp save path tmp_path = xbmc.translatePath("special://temp/%s.flv" % (video_id,)) # get a valid filepath if self.settings["use_title"]: # add extension to video title title = self.g_title + ".flv" else: # we use the urls trailer name title = video_id + ".flv" # make the path legal for the users platform self.filepath = self._make_legal_filepath(title) # get the filesystem the trailer will be saved to filesystem = self._get_filesystem() # win32 requires encoding to work proper if self._get_filesystem() == "win32": filepath = self.filepath.encode("utf-8") else: filepath = self.filepath # only download if the trailer doesn't exist if not os.path.isfile(tmp_path) and not os.path.isfile(self.filepath): # fetch the video urllib.urlretrieve(url, tmp_path, self._report_hook) ok = True # finalize if not os.path.isfile(filepath): # copy to final location ok = self._finalize_download(tmp_path) # if the copy failed raise an error if not ok: raise except: print "ERROR: %s::%s (%d) - %s" % ( self.__class__.__name__, sys.exc_info()[2].tb_frame.f_code.co_name, sys.exc_info()[2].tb_lineno, sys.exc_info()[1], ) # filepath is not always released immediately, we may need to try more than one attempt, sleeping between urllib.urlcleanup() remove_tries = 3 while remove_tries and os.path.isfile(tmp_path): try: os.remove(tmp_path) except: remove_tries -= 1 xbmc.sleep(1000) pDialog.close() self.filepath = ""
def _get_settings( self ): self.settings = {} self.settings[ "path" ] = self._get_path_list( xbmcplugin.getSetting( "path" ) ) self.settings[ "content" ] = xbmcplugin.getSetting( "content" ) self.settings[ "macaddress" ] = xbmcplugin.getSetting( "macaddress" ) self.settings[ "port" ] = int( xbmcplugin.getSetting( "port" ) ) self.settings[ "retries" ] = int( xbmcplugin.getSetting( "retries" ) ) + 1 self.media_type = ( "video" in os.getcwd() ) # we need to set self.args.path self.args = _Info( path=self.settings[ "path" ] )
def __init__(self, pt=False): self.handle = int(sys.argv[1]) self.ws_limit = False #web search limit self.defs = defs self.window = ui.listwindow('select.xml', addon_dir, 'Default', '720p', ump=self) self.iwindow = ui.imagewindow('picture.xml', addon_dir, "Default", "720p") self.urlval_en = True self.urlval_tout = 60 self.urlval_d_size = { self.defs.CT_VIDEO: 1000000, self.defs.CT_AUDIO: 10000, self.defs.CT_IMAGE: 200 } self.urlval_d_tout = 1.5 self.tm_conc = int(xbmcplugin.getSetting(self.handle, "conc")) self.player = None self.mirrors = [] self.terminate = False self.tm = task.manager(self.tm_conc) self.loaded_uprv = {} self.checked_uids = {"video": {}, "audio": {}, "image": {}} self.pt = pt if xbmcplugin.getSetting(self.handle, "kodiproxy") == "true": from ump import proxy socket.socket = proxy.socket() self.cj = LWPCookieJar( os.path.join(addon_dir, 'resources', 'data', "cookie")) if os.path.exists( os.path.join(addon_dir, 'resources', 'data', "cookie")): try: self.cj.load() except LoadError: pass self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor( self.cj)) self.ua = xbmcplugin.getSetting(self.handle, "useragent") self.opener.addheaders = [('User-agent', self.ua)] self.dialog = xbmcgui.Dialog() query = sys.argv[2][1:] result = urlparse.parse_qs(query) [self.module] = result.get('module', ["ump"]) [self.page] = result.get('page', ["root"]) [args] = result.get('args', ["{}"]) self.args = json.loads(args) for keep in ["info", "art"]: [lst] = result.get(keep, ["{}"]) setattr(self, keep, json.loads(lst)) [self.content_type] = result.get('content_type', ["index"]) [self.content_cat] = result.get('content_cat', ["N/A"]) self.loadable_uprv = providers.find(self.content_type, "url")
def getlowurl(code): xbmc.output("[megavideo.py] Baja calidad") code=getcode(code) modoPremium = xbmcplugin.getSetting("megavideopremium") xbmc.output("[megavideo.py] modoPremium="+modoPremium) if modoPremium == "false": xbmc.output("[megavideo.py] usando modo normal para baja calidad") req = urllib2.Request("http://www.megavideo.com/xml/videolink.php?v="+code) req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14') req.add_header('Referer', 'http://www.megavideo.com/') page = urllib2.urlopen(req);response=page.read();page.close() errort = re.compile(' errortext="(.+?)"').findall(response) movielink = "" if len(errort) <= 0: s = re.compile(' s="(.+?)"').findall(response) k1 = re.compile(' k1="(.+?)"').findall(response) k2 = re.compile(' k2="(.+?)"').findall(response) un = re.compile(' un="(.+?)"').findall(response) movielink = "http://www" + s[0] + ".megavideo.com/files/" + decrypt(un[0], k1[0], k2[0]) + "/?.flv" #addLink(name, movielink+'?.flv','') else: xbmc.output("[megavideo.py] usando modo premium para baja calidad") megavideocookie = xbmcplugin.getSetting("megavideocookie") if DEBUG: xbmc.output("[megavideo.py] megavideocookie=#"+megavideocookie+"#") #if megavideocookie=="": xbmc.output("[megavideo.py] Averiguando cookie...") megavideologin = xbmcplugin.getSetting("megavideouser") if DEBUG: xbmc.output("[megavideo.py] megavideouser=#"+megavideologin+"#") megavideopassword = xbmcplugin.getSetting("megavideopassword") if DEBUG: xbmc.output("[megavideo.py] megavideopassword=#"+megavideopassword+"#") megavideocookie = GetMegavideoUser(megavideologin, megavideopassword) if DEBUG: xbmc.output("[megavideo.py] megavideocookie=#"+megavideocookie+"#") req = urllib2.Request("http://www.megavideo.com/xml/videolink.php?v="+code+"&u="+megavideocookie) req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14') req.add_header('Referer', 'http://www.megavideo.com/') page = urllib2.urlopen(req);response=page.read();page.close() errort = re.compile(' errortext="(.+?)"').findall(response) movielink = "" if len(errort) <= 0: s = re.compile(' s="(.+?)"').findall(response) k1 = re.compile(' k1="(.+?)"').findall(response) k2 = re.compile(' k2="(.+?)"').findall(response) un = re.compile(' un="(.+?)"').findall(response) movielink = "http://www" + s[0] + ".megavideo.com/files/" + decrypt(un[0], k1[0], k2[0]) + "/?.flv" #addLink(name, movielink+'?.flv','') return movielink
def gethighurl(code): megavideologin = xbmcplugin.getSetting("megavideouser") if DEBUG: xbmc.output("[megaupload.py] megavideouser=#"+megavideologin+"#") megavideopassword = xbmcplugin.getSetting("megavideopassword") if DEBUG: xbmc.output("[megaupload.py] megavideopassword=#"+megavideopassword+"#") cookie = getmegauploaduser(megavideologin,megavideopassword) if DEBUG: xbmc.output("[megaupload.py] cookie=#"+cookie+"#") return getmegauploadvideo(code,cookie)
def playVideo(episodeid, name, thumbnail): if xbmcplugin.getSetting(pluginhandle, "bitrate") == "0": lbitrate = None elif xbmcplugin.getSetting(pluginhandle, "bitrate") == "1": lbitrate = 700 elif xbmcplugin.getSetting(pluginhandle, "bitrate") == "2": lbitrate = 600 dname = name swfurl = "http://media.mtvnservices.com/player/release/?v=4.5.3" url = ( "http://www.southparkstudios.com/feeds/video-player/mrss/mgid%3Acms%3Acontent%3Asouthparkstudios.com%3A" + episodeid ) # url = 'http://media.mtvnservices.com/player/config.jhtml?uri=mgid%3Acms%3Acontent%3Asouthparkstudios.com%3A'+episodeid+'&group=entertainment&type=network' response = getURL(url) # rtmp=re.compile('<media:content url="(.+?)" type="text/xml" medium="video" duration=".+?" isDefault=".+?" />').findall(response) rtmp = re.compile('<media:content type=".+?" medium=".+?" duration=".+?" isDefault=".+?" url="(.+?)" />').findall( response ) stacked_url = "stack://" for url in rtmp: response = getURL(url) rtmps = re.compile("<src>(.+?)</src>").findall(response) hbitrate = 0 hwidth = 0 furl = False for rtmpbit in rtmps: filesplit = rtmpbit.split("/")[-1] brsplit = filesplit.split("_") bitrate = int(brsplit[-1].split(".")[-2].replace("kbps", "")) resolution = brsplit[-2].split("x") pixels = int(resolution[0]) * int(resolution[1]) if bitrate > hbitrate or pixels > hpixels: if lbitrate == None or bitrate <= lbitrate: hbitrate = bitrate hpixels = pixels furl = rtmpbit + " swfurl=" + swfurl + " swfvfy=true" if furl is not False: stacked_url += furl.replace(",", ",,") + " , " stacked_url = stacked_url[:-3] item = xbmcgui.ListItem(dname, thumbnailImage=thumbnail, path=stacked_url) item.setInfo( type="Video", infoLabels={ "Title": dname, "Season": season, "Episode": episode, "premiered": premiered, "Plot": plot, "TVShowTitle": TVShowTitle, }, ) xbmcplugin.setResolvedUrl(pluginhandle, True, item)
def configMac(number): custom_mac = xbmcplugin.getSetting(int(sys.argv[1]), 'custom_mac_' + number); portal_mac = xbmcplugin.getSetting(int(sys.argv[1]), 'portal_mac_' + number); if custom_mac != 'true': portal_mac = ''; elif not (custom_mac == 'true' and re.match("[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", portal_mac.lower()) != None): xbmcgui.Dialog().notification(addonname, 'Custom Mac ' + number + ' is Invalid.', xbmcgui.NOTIFICATION_ERROR ); portal_mac = ''; return portal_mac;
def __init__(self): self.br = Browser() self.ip = xbmcplugin.getSetting("ip") self.port = xbmcplugin.getSetting("port") self.usr = xbmcplugin.getSetting("usr") self.pwd = xbmcplugin.getSetting("pwd") self.tdir = xbmcplugin.getSetting("tdir") self.lang = xbmc.Language(os.getcwd()).getLocalizedString self.dialog = xbmcgui.Dialog()