The branch, dharma has been updated
via 4e8bed22e21be2279b9e526e55906cc7d7a12238 (commit)
from 403d305bb05ee8e3528af97eeb29237e582ccc0c (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=4e8bed22e21be2279b9e526e55906cc7d7a12238
commit 4e8bed22e21be2279b9e526e55906cc7d7a12238
Author: spiff <[email protected]>
Date: Tue Oct 25 16:12:57 2011 +0200
[plugin.video.youtube] updated to version 2.1.2
diff --git a/plugin.video.youtube/YouTubeCore.py
b/plugin.video.youtube/YouTubeCore.py
index 944ecd7..0440e84 100755
--- a/plugin.video.youtube/YouTubeCore.py
+++ b/plugin.video.youtube/YouTubeCore.py
@@ -18,6 +18,8 @@
import sys, urllib, urllib2, re, os, cookielib, string
from xml.dom.minidom import parseString
+import YouTubeLogin
+login = YouTubeLogin.YouTubeLogin()
# ERRORCODES:
# 0 = Ignore
@@ -71,92 +73,6 @@ class YouTubeCore(object):
doc = doc.strip() # Remove leading/trailing
whitespace.
firstline = doc.split('\n')[0]
print "DOC: ", firstline
-
- def login(self, error = 0):
- if self.__dbg__:
- print self.__plugin__ + " login - errors: " + str(error)
-
- uname = self.__settings__.getSetting( "username" )
- passwd = self.__settings__.getSetting( "user_password" )
-
- self.__settings__.setSetting('auth', "")
- self.__settings__.setSetting('nick', "")
-
- if ( uname == "" or passwd == "" ):
- if self.__dbg__:
- print self.__plugin__ + " login no username or
password set "
- return ( "", 0 )
-
- url =
urllib2.Request("https://www.google.com/youtube/accounts/ClientLogin")
-
- url.add_header('Content-Type',
'application/x-www-form-urlencoded')
- url.add_header('GData-Version', '2')
-
- data = urllib.urlencode({'Email': uname, 'Passwd': passwd,
'service': 'youtube', 'source': 'YouTube plugin'})
-
- try:
- con = urllib2.urlopen(url, data);
-
- value = con.read()
- con.close()
-
- result =
re.compile('Auth=(.*)\nYouTubeUser=(.*)').findall(value)
-
- if len(result) > 0:
- ( auth, nick ) = result[0]
- self.__settings__.setSetting('auth', auth)
- self.__settings__.setSetting('nick', nick)
-
- if self.__dbg__:
- print self.__plugin__ + " login done: "
+ nick
- return ( self.__language__(30030), 200 )
-
- return ( self.__language__(30609), 303 )
-
- except urllib2.HTTPError, e:
- err = str(e)
- if self.__dbg__:
- print self.__plugin__ + " login failed, hit
http except: " + err
- if e.code == 403:
- return ( self.__language__(30621), 303 )
- return ( err, 303 )
-
- except ValueError, e:
- err = repr(e)
- if self.__dbg__:
- print self.__plugin__ + " login failed, hit
valueerror except: " + err
- return ( err, 303 )
-
- except IOError, e:
- #
http://bytes.com/topic/python/answers/33770-error-codes-urlerror
- if self.__dbg__:
- print self.__plugin__ + " login failed, hit
ioerror except2: : " + repr(e)
- 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])
- print self.interrogate(e)
-
- if error < 9:
- if self.__dbg__:
- print self.__plugin__ + " login pre
sleep"
- # Check if there is a timeout here.
- import time
- time.sleep(3)
- if self.__dbg__:
- print self.__plugin__ + " login post
sleep"
- return self.login( error + 1 )
- return ( self.__language__(30623), 303 )
-
- except urllib2.URLError, e:
- err = repr(e)
- if self.__dbg__:
- print self.__plugin__ + " login failed, hit url
except: " + err
- return ( err, 303 )
- except:
- if self.__dbg__:
- print self.__plugin__ + " login failed uncaught
exception"
- 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])
- return ( self.__language__(30609), 500 )
def search(self, query, page = "0"):
if self.__dbg__:
@@ -238,7 +154,7 @@ class YouTubeCore(object):
if self.__dbg__:
print self.__plugin__ + " list: " + repr(feed) + " -
page: " + repr(page)
result = ""
- auth = self._getAuth()
+ auth = login._getAuth()
if ( not auth ):
if self.__dbg__:
print self.__plugin__ + " playlists auth wasn't
set "
@@ -304,7 +220,7 @@ class YouTubeCore(object):
print self.__plugin__ + " playlists " + repr(link) + "
- page: " + repr(get("page","0"))
result = ""
- auth = self._getAuth()
+ auth = login._getAuth()
if ( not auth ):
if self.__dbg__:
print self.__plugin__ + " playlists auth wasn't
set "
@@ -506,10 +422,23 @@ class YouTubeCore(object):
#
#===============================================================================
- def _fetchPage(self, link, api = False, auth=False, login=False, error
= 0):
+ def _fetchPage(self, link, api = False, auth=False, doLogin=False,
error = 0):
if self.__dbg__:
print self.__plugin__ + " fetching page : " + link
+
+ if auth:
+ print self.__plugin__ + "got auth"
+ if login._getAuth():
+ if link.find("?") > -1:
+ link += "&oauth_token=" +
self.__settings__.getSetting("oauth2_access_token")
+ else:
+ link += "?oauth_token=" +
self.__settings__.getSetting("oauth2_access_token")
+
+ print self.__plugin__ + "updated link: " + link
+ else:
+ print self.__plugin__ + "couldn't get login
token"
+
request = urllib2.Request(link)
if api:
@@ -517,24 +446,21 @@ class YouTubeCore(object):
else:
request.add_header('User-Agent', self.USERAGENT)
- if ( login ):
- if ( self.__settings__.getSetting( "username" ) == ""
or self.__settings__.getSetting( "user_password" ) == "" ):
- if self.__dbg__:
- print self.__plugin__ + " _fetchPage,
login required but no credentials provided"
- return ( self.__language__( 30608 ) , 303 )
+ if ( doLogin ):
+ print self.__plugin__ + "got login"
+ if (self.__settings__.getSetting("username") == "" or
self.__settings__.getSetting("user_password") == ""):
+ print self.__plugin__ + "_fetchPage, login
required but no credentials provided"
+ ret_obj["status"] = 303
+ ret_obj["content"] = self.__language__(30622)
+ return ret_obj
- if self.__dbg__:
- print self.__plugin__ + " _fetchPage adding
cookie"
- request.add_header('Cookie', 'LOGIN_INFO=' +
self._httpLogin() )
-
- if auth:
- authkey = self._getAuth()
- if ( not authkey ):
- if self.__dbg__:
- print self.__plugin__ + " _fetchPage
couldn't set auth "
-
- request.add_header('Authorization', 'GoogleLogin auth='
+ authkey)
- request.add_header('X-GData-Key', 'key=' + self.APIKEY)
+ if self.__settings__.getSetting("login_info") == "":
+ self._httpLogin()
+
+ if self.__settings__.getSetting("login_info") != "":
+ print self.__plugin__ + "returning existing
login info: " + self.__settings__.getSetting("login_info")
+ info =
self.__settings__.getSetting("login_info")
+ request.add_header('Cookie', 'LOGIN_INFO=' +
info)
try:
con = urllib2.urlopen(request)
@@ -547,7 +473,7 @@ class YouTubeCore(object):
return ( result, 200 )
elif ( error < 10 ):
# We need login to verify age.
- if not login:
+ if not doLogin:
if self.__dbg__:
print self.__plugin__ + "
_fetchPage age verification required, retrying with login"
error = error + 0
@@ -555,7 +481,7 @@ class YouTubeCore(object):
if self.__dbg__:
print self.__plugin__ + " _fetchPage
verifying age"
- return self._verifyAge(result, new_url, link,
api, auth, login, error)
+ return login._verifyAge(result, new_url, link,
api, auth, login, error)
if self.__dbg__:
print self.__plugin__ + " _fetchPage. Too many
errors"
@@ -572,11 +498,11 @@ class YouTubeCore(object):
# 401 (Not authorized) - A 401 response code indicates
that a request did not contain an Authorization header, that the format of the
Authorization header was invalid, or that the authentication token supplied in
the header was invalid.
elif ( err.find("401") > -1 ):
# If login credentials are given, try again.
- if ( self.__settings__.getSetting( "username" )
== "" or self.__settings__.getSetting( "user_password" ) == "" ):
+ if ( self.__settings__.getSetting( "username" )
!= "" and self.__settings__.getSetting( "user_password" ) != "" ):
if self.__dbg__:
print self.__plugin__ + "
_fetchPage trying again with login "
- self.login()
+ login.login()
return self._fetchPage(link, api, auth,
login, error +1)
else:
if self.__dbg__:
@@ -609,67 +535,6 @@ class YouTubeCore(object):
return ( "", 500 )
- def _verifyAge(self, result, new_url, link, api = False, auth=False,
login=False, error = 0):
- login_info = self._httpLogin(True)
- confirmed = "0"
- if self.__settings__.getSetting( "safe_search" ) != "2":
- confirmed = "1"
-
- request = urllib2.Request(new_url)
- request.add_header('User-Agent', self.USERAGENT)
- request.add_header('Cookie', 'LOGIN_INFO=' + login_info)
- con = urllib2.urlopen(request)
- result = con.read()
-
- # Fallback for missing confirm form.
- if result.find("confirm-age-form") == -1:
- if self.__dbg__ or True:
- print self.__plugin__ + " Failed trying to
verify-age could find confirm age form."
- print self.__plugin__ + " html page given: " +
repr(result)
- return ( self.__language__( 30600 ) , 303 )
-
- # get next_url
- next_url_start = result.find('"next_url" value="') +
len('"next_url" value="')
- next_url_stop = result.find('">',next_url_start)
- next_url = result[next_url_start:next_url_stop]
-
- if self.__dbg__:
- print self.__plugin__ + " next_url=" + next_url
-
- # get session token to get around the cross site scripting
prevetion
- session_token_start = result.find("'XSRF_TOKEN': '") +
len("'XSRF_TOKEN': '")
- session_token_stop = result.find("',",session_token_start)
- session_token = result[session_token_start:session_token_stop]
-
- if self.__dbg__:
- print self.__plugin__ + " session_token=" +
session_token
-
- # post collected information to age the verifiaction page
- request = urllib2.Request(new_url)
- request.add_header('User-Agent', self.USERAGENT)
- request.add_header('Cookie', 'LOGIN_INFO=' + login_info )
-
request.add_header("Content-Type","application/x-www-form-urlencoded")
- values = urllib.urlencode( { "next_url": next_url,
"action_confirm": confirmed, "session_token":session_token })
-
- if self.__dbg__:
- print self.__plugin__ + " post page content: " + values
-
- con = urllib2.urlopen(request, values)
- new_url = con.geturl()
- result = con.read()
- con.close()
-
- #If verification is success full new url must look like:
'http://www.youtube.com/index?has_verified=1'
- if new_url.find("has_verified=1") > 0:
- if self.__dbg__:
- print self.__plugin__ + " Age Verification
sucessfull " + new_url
- return self._fetchPage(link, api, auth, login = True,
error = error + 1)
-
- # If verification failed we dump a shit load of info to the logs
- print self.__plugin__ + " age verification failed with result:
" + repr(result)
- print self.__plugin__ + " result url: " + repr(new_url)
- return (self.__language__(30600), 303)
-
def _extractVariables(self, videoid):
if self.__dbg__:
@@ -699,33 +564,11 @@ class YouTubeCore(object):
print self.__plugin__ + " extractVariables done"
return (fmtSource, swf_url, stream_map)
-
- def _getAuth(self):
- if self.__dbg__:
- print self.__plugin__ + " _getAuth"
-
- auth = self.__settings__.getSetting( "auth" )
-
- if ( auth ):
- if self.__dbg__:
- print self.__plugin__ + " _getAuth returning
stored auth"
- return auth
- else:
- (result, status ) = self.login()
- if status == 200:
- if self.__dbg__:
- print self.__plugin__ + " _getAuth
returning new auth"
-
- return self.__settings__.getSetting( "auth" )
- else:
- if self.__dbg__:
- print self.__plugin__ + " _getAuth
failed because login failed"
- return False
def _youTubeAdd(self, url, add_request, retry = True):
if self.__dbg__:
print self.__plugin__ + " _youTubeAdd: " + repr(url) +
" add_request " + repr(add_request)
- auth = self._getAuth()
+ auth = login._getAuth()
if ( not auth ):
if self.__dbg__:
print self.__plugin__ + " playlists auth wasn't
set "
@@ -759,7 +602,7 @@ class YouTubeCore(object):
if self.__dbg__:
print self.__plugin__ + "
_youTubeAdd trying again with login "
- self.login()
+ login.login()
#def _fetchPage(self, link, api =
False, auth=False, login=False, error = 0):
return self._youTubeAdd(url,
add_request, False)
#return self._fetchPage(link, api,
auth, login, error + 1)
@@ -776,7 +619,7 @@ class YouTubeCore(object):
if self.__dbg__:
print self.__plugin__ + " _youTubeDel: " + delete_url
- auth = self._getAuth()
+ auth = login._getAuth()
if ( not auth ):
if self.__dbg__:
print self.__plugin__ + " _youTubeDel auth
wasn't set "
@@ -804,7 +647,7 @@ class YouTubeCore(object):
if self.__dbg__:
print self.__plugin__ + "
_youTubeDel trying again with login "
- self.login()
+ login.login()
return self._youTubeDel(delete_url,
False);
#return self._fetchPage(link, api,
auth, login, error +1)
else:
@@ -1118,109 +961,4 @@ class YouTubeCore(object):
video['apierror'] = self.__language__(30606) +
str(status)
return video
- def _httpLogin(self, new = False, error = 0):
- if self.__dbg__:
- print self.__plugin__ + " _httpLogin errors: " +
str(error)
-
- uname = self.__settings__.getSetting( "username" )
- pword = self.__settings__.getSetting( "user_password" )
-
- if ( uname == "" and pword == "" ):
- return ""
-
- if ( new ):
- if self.__dbg__:
- print self.__plugin__ + " _httpLogin clearing
login_info"
- self.__settings__.setSetting( "login_info", "" )
- elif ( self.__settings__.getSetting( "login_info" ) != "" ):
- if self.__dbg__:
- print self.__plugin__ + " _httpLogin returning
stored login_info"
-
- return self.__settings__.getSetting( "login_info" )
-
- cj = cookielib.LWPCookieJar()
-
- opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
- urllib2.install_opener(opener)
- # Get GALX
- url =
urllib2.Request(urllib.unquote("https://www.google.com/accounts/ServiceLogin?service=youtube"))
- url.add_header('User-Agent', self.USERAGENT)
-
- try:
- if self.__dbg__:
- print self.__plugin__ + " _httpLogin: getting
new login_info"
- con = urllib2.urlopen(url)
- header = con.info()
- galx = re.compile('Set-Cookie:
GALX=(.*);Path=/accounts;Secure').findall(str(header))[0]
-
- cont =
urllib.unquote("http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Den_US%26next%3D%252Findex&hl=en_US<mpl=sso")
-
- params = urllib.urlencode({'GALX': galx,
- 'Email': uname,
- 'Passwd': pword,
- 'PersistentCookie': 'yes',
- 'continue': cont})
-
- # Login to Google
- url =
urllib2.Request('https://www.google.com/accounts/ServiceLoginAuth?service=youtube',
params)
- url.add_header('User-Agent', self.USERAGENT)
-
- con = urllib2.urlopen(url)
- result = con.read()
-
- newurl = re.compile('<meta http-equiv="refresh"
content="0; url='(.*)'"></head>').findall(result)[0].replace("&",
"&")
- url = urllib2.Request(newurl)
- url.add_header('User-Agent', self.USERAGENT)
- con = urllib2.urlopen(newurl)
- result = con.read()
- con.close()
-
- newurl = re.compile('<meta http-equiv="refresh"
content="0; url='(.*)'"></head>').findall(result)[0].replace("&",
"&")
- url = urllib2.Request(newurl)
- url.add_header('User-Agent', self.USERAGENT)
- con = urllib2.urlopen(newurl)
- result = con.read()
- con.close()
-
- # Save cookiefile in settings
- cookies = repr(cj)
- login_info = ""
- if cookies.find("name='LOGIN_INFO', value='") > 0:
- start = cookies.find("name='LOGIN_INFO',
value='") + len("name='LOGIN_INFO', value='")
- login_info = cookies[start:cookies.find("',
port=None", start)]
-
- self.__settings__.setSetting( "login_info", login_info )
-
- if self.__dbg__:
- print self.__plugin__ + " _httpLogin done: " +
login_info
-
- return self.__settings__.getSetting( "login_info" )
-
- except IOError, e:
- #
http://bytes.com/topic/python/answers/33770-error-codes-urlerror
- if self.__dbg__:
- print self.__plugin__ + " login failed, hit
ioerror except2: : " + repr(e)
- 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])
- print self.interrogate(e)
-
- if error < 9:
- if self.__dbg__:
- print self.__plugin__ + " login
pre sleep"
- # Check if there is a timeout here.
- import time
- time.sleep(3)
- if self.__dbg__:
- print self.__plugin__ + " login
post sleep"
-
- return self._httpLogin( new, error + 1 )
-
- return ""
- except:
- if self.__dbg__:
- print self.__plugin__ + " _httpLogin: uncaught
exception"
- 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])
- return ""
-
diff --git a/plugin.video.youtube/YouTubeNavigation.py
b/plugin.video.youtube/YouTubeNavigation.py
index 99a0791..b6ab225 100644
--- a/plugin.video.youtube/YouTubeNavigation.py
+++ b/plugin.video.youtube/YouTubeNavigation.py
@@ -23,10 +23,12 @@ import xbmcgui
import xbmcplugin
import urllib
import YouTubeCore
+import YouTubeLogin
import YouTubePlayer
import YouTubeScraperCore
core = YouTubeCore.YouTubeCore()
+login = YouTubeLogin.YouTubeLogin()
scraper = YouTubeScraperCore.YouTubeScraperCore()
player = YouTubePlayer.YouTubePlayer()
@@ -76,8 +78,8 @@ class YouTubeNavigation:
{'Title':__language__( 30041 )
,'path':"/root/explore/categories" , 'thumbnail':"explore"
, 'login':"false" , 'scraper':'categories'},
{'Title':__language__( 30037 )
,'path':"/root/explore/disco" , 'thumbnail':"discoball"
, 'login':"false" , 'store':"disco_searches" },
{'Title':__language__( 30040 )
,'path':"/root/explore/disco/search" , 'thumbnail':"search"
, 'login':"false" , 'action':"search_disco"},
- {'Title':__language__( 30038 )
,'path':"/root/explore/disco/top_25" , 'thumbnail':"discoball"
, 'login':"false" , 'scraper':"disco_top_25"},
- {'Title':__language__( 30039 )
,'path':"/root/explore/disco/popular" , 'thumbnail':"discoball"
, 'login':"false" , 'scraper':"disco_top_artist"},
+# {'Title':__language__( 30038 )
,'path':"/root/explore/disco/top_25" , 'thumbnail':"discoball"
, 'login':"false" , 'scraper':"disco_top_25"},
+# {'Title':__language__( 30039 )
,'path':"/root/explore/disco/popular" , 'thumbnail':"discoball"
, 'login':"false" , 'scraper':"disco_top_artist"},
{'Title':__language__( 30001 )
,'path':"/root/explore/feeds" , 'thumbnail':"feeds"
, 'login':"false" },
{'Title':__language__( 30009 )
,'path':"/root/explore/feeds/discussed" , 'thumbnail':"most"
, 'login':"false" , 'feed':"feed_discussed" },
{'Title':__language__( 30010 )
,'path':"/root/explore/feeds/linked" , 'thumbnail':"most"
, 'login':"false" , 'feed':"feed_linked" },
@@ -87,13 +89,13 @@ class YouTubeNavigation:
{'Title':__language__( 30014 )
,'path':"/root/explore/feeds/featured" , 'thumbnail':"featured"
, 'login':"false" , 'feed':"feed_featured" },
{'Title':__language__( 30015 )
,'path':"/root/explore/feeds/favorites" , 'thumbnail':"top"
, 'login':"false" , 'feed':"feed_favorites" },
{'Title':__language__( 30016 )
,'path':"/root/explore/feeds/rated" , 'thumbnail':"top"
, 'login':"false" , 'feed':"feed_rated" },
- {'Title':__language__( 30043 )
,'path':"/root/explore/movies" , 'thumbnail':"movies"
, 'login':"false" , 'scraper':'movies'},
- {'Title':__language__( 30042 )
,'path':"/root/explore/shows" , 'thumbnail':"shows"
, 'login':"false" , 'scraper':'shows'},
- {'Title':__language__( 30032 )
,'path':"/root/explore/trailers" , 'thumbnail':"trailers"
, 'login':"false" },
- {'Title':__language__( 30035 )
,'path':"/root/explore/trailers/latest" , 'thumbnail':"trailers"
, 'login':"false" , 'scraper':"latest_trailers" },
- {'Title':__language__( 30034 )
,'path':"/root/explore/trailers/current" , 'thumbnail':"trailers"
, 'login':"false" , 'scraper':"current_trailers" },
- {'Title':__language__( 30036 )
,'path':"/root/explore/trailers/upcoming" , 'thumbnail':"trailers"
, 'login':"false" , 'scraper':"upcoming_trailers" },
- {'Title':__language__( 30033 )
,'path':"/root/explore/trailers/popular" , 'thumbnail':"trailers"
, 'login':"false" , 'scraper':"popular_trailers" },
+# {'Title':__language__( 30043 )
,'path':"/root/explore/movies" , 'thumbnail':"movies"
, 'login':"false" , 'scraper':'movies'},
+# {'Title':__language__( 30042 )
,'path':"/root/explore/shows" , 'thumbnail':"shows"
, 'login':"false" , 'scraper':'shows'},
+# {'Title':__language__( 30032 )
,'path':"/root/explore/trailers" , 'thumbnail':"trailers"
, 'login':"false" },
+# {'Title':__language__( 30035 )
,'path':"/root/explore/trailers/latest" , 'thumbnail':"trailers"
, 'login':"false" , 'scraper':"latest_trailers" },
+# {'Title':__language__( 30034 )
,'path':"/root/explore/trailers/current" , 'thumbnail':"trailers"
, 'login':"false" , 'scraper':"current_trailers" },
+# {'Title':__language__( 30036 )
,'path':"/root/explore/trailers/upcoming" , 'thumbnail':"trailers"
, 'login':"false" , 'scraper':"upcoming_trailers" },
+# {'Title':__language__( 30033 )
,'path':"/root/explore/trailers/popular" , 'thumbnail':"trailers"
, 'login':"false" , 'scraper':"popular_trailers" },
{'Title':__language__( 30019 )
,'path':"/root/recommended" ,
'thumbnail':"recommended" , 'login':"true" ,
'scraper':"recommended" },
{'Title':__language__( 30018 )
,'path':"/root/contacts" ,
'thumbnail':"contacts" , 'login':"true" ,
'feed':"contacts" },
{'Title':__language__( 30002 )
,'path':"/root/favorites" ,
'thumbnail':"favorites" , 'login':"true" ,
'feed':"favorites" },
@@ -178,7 +180,7 @@ class YouTubeNavigation:
if (get("action") == "delete_refinements"):
self.deleteRefinements(params)
if (get("action") == "settings"):
- self.login(params)
+ login.login(params)
if (get("action") == "delete_search" or get("action") ==
"delete_disco"):
self.deleteSearch(params)
if (get("action") == "edit_search" or get("action") ==
"edit_disco"):
@@ -207,10 +209,10 @@ class YouTubeNavigation:
def listOptionFolder(self, params = {}):
get = params.get
if ( get('login') and self.__settings__.getSetting( "username"
) != "" ):
- auth = self.__settings__.getSetting( "auth" )
+ auth = self.__settings__.getSetting(
"oauth2_access_token" )
if ( not auth ) :
- self.login()
- auth = self.__settings__.getSetting( "auth" )
+ login.login()
+ auth = self.__settings__.getSetting(
"oauth2_access_token" )
item_favorites = {'Title':self.__language__( 30020 ),
'path':get("path"), 'external':"true", 'login':"true", 'thumbnail':"favorites",
'feed':"favorites", "contact":get("contact")}
self.addFolderListItem(params, item_favorites, 1)
@@ -242,10 +244,10 @@ class YouTubeNavigation:
def listUserFolder(self, params = {}):
get = params.get
if ( get('login') and self.__settings__.getSetting( "username"
) != "" ):
- auth = self.__settings__.getSetting( "auth" )
+ auth = self.__settings__.getSetting(
"oauth2_access_token" )
if ( not auth ) :
- self.login()
- auth = self.__settings__.getSetting( "auth" )
+ login.login()
+ auth = self.__settings__.getSetting(
"oauth2_access_token" )
feed = self.parseFeeds(params)
@@ -282,10 +284,10 @@ class YouTubeNavigation:
def listUserFolderFeeds(self, params = {}):
get = params.get
if ( get('login') and self.__settings__.getSetting( "username"
) != "" ):
- auth = self.__settings__.getSetting( "auth" )
+ auth = self.__settings__.getSetting(
"oauth2_access_token" )
if ( not auth ) :
- self.login()
- auth = self.__settings__.getSetting( "auth" )
+ login.login()
+ auth = self.__settings__.getSetting(
"oauth2_access_token" )
feed = self.parseFeeds(params)
@@ -316,9 +318,7 @@ class YouTubeNavigation:
self.parseVideoList(params, result);
def login(self, params = {}):
- self.__settings__.openSettings()
-
- (result, status) = core.login()
+ (result, status) = login.login()
if status == 200:
self.errorHandling(self.__language__(30031), result,
303)
@@ -703,11 +703,11 @@ class YouTubeNavigation:
if (item("login") == "false"):
self.addFolderListItem(params, item_params)
else:
- if (len(self.__settings__.getSetting( "auth" ))
> 0):
+ if (len(self.__settings__.getSetting(
"oauth2_access_token" )) > 0):
self.addFolderListItem(params,
item_params)
else :
if (item("action") == "settings"):
- if (len(self.__settings__.getSetting( "auth" ))
> 0):
+ if (len(self.__settings__.getSetting(
"oauth2_access_token" )) > 0):
if (item("login") == "true"):
self.addActionListItem(params,
item_params)
else:
@@ -788,7 +788,6 @@ class YouTubeNavigation:
listitem.setProperty( "Video", "true" )
listitem.setProperty( "IsPlayable", "true")
listitem.setInfo(type='Video', infoLabels=item_params)
- xbmcplugin.setContent( handle=int( sys.argv[ 1 ] ),
content="movies" )
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url,
listitem=listitem, isFolder=False, totalItems=listSize + 1)
#==================================== Core Output Parsing Functions
===========================================
@@ -977,7 +976,7 @@ class YouTubeNavigation:
cm.append( ( self.__language__(30501),
"XBMC.RunPlugin(%s?path=%s&action=download&videoid=%s)" % ( sys.argv[0],
item("path"), item("videoid") ) ) )
- if ( self.__settings__.getSetting( "username" ) != ""
and self.__settings__.getSetting( "auth" ) ):
+ if ( self.__settings__.getSetting( "username" ) != ""
and self.__settings__.getSetting( "oauth2_access_token" ) ):
if ( get("feed") == "favorites" and not
get("contact") ):
cm.append( ( self.__language__( 30506
), 'XBMC.RunPlugin(%s?path=%s&action=remove_favorite&editid=%s&)' % (
sys.argv[0], item("path"), item("editid") ) ) )
else:
@@ -1033,14 +1032,14 @@ class YouTubeNavigation:
cm.append( (self.__language__( 30528 ),
cm_url % ("subscriptions_playlists")))
if (item("channel")):
- if ( self.__settings__.getSetting( "username" )
!= "" and self.__settings__.getSetting( "auth" ) ):
+ if ( self.__settings__.getSetting( "username" )
!= "" and self.__settings__.getSetting( "oauth2_access_token" ) ):
if (get("external")):
cm.append( ( self.__language__(
30512 ) % item("channel"),
'XBMC.RunPlugin(%s?path=%s&channel=%s&action=add_subscription)' % (
sys.argv[0], item("path"), item("channel") ) ) )
else:
cm.append( ( self.__language__(
30513 ) % item("channel"),
'XBMC.RunPlugin(%s?path=%s&editid=%s&action=remove_subscription)' % (
sys.argv[0], item("path"), item("editid") ) ) )
if (item("contact")):
- if ( self.__settings__.getSetting( "username" )
!= "" and self.__settings__.getSetting( "auth" ) ):
+ if ( self.__settings__.getSetting( "username" )
!= "" and self.__settings__.getSetting( "oauth2_access_token" ) ):
if (item("external")):
cm.append(
(self.__language__(30026), 'XBMC.RunPlugin(%s?path=%s&action=add_contact&)' % (
sys.argv[0], item("path") ) ) )
else:
diff --git a/plugin.video.youtube/YouTubePlayer.py
b/plugin.video.youtube/YouTubePlayer.py
index 0b460f8..feb1766 100755
--- a/plugin.video.youtube/YouTubePlayer.py
+++ b/plugin.video.youtube/YouTubePlayer.py
@@ -72,22 +72,22 @@ class YouTubePlayer:
print self.__plugin__ + " getVideoUrlMap: "
links = {}
video["url_map"] = "true"
-
+
html = ""
if pl_obj["args"].has_key("fmt_stream_map"):
html = pl_obj["args"]["fmt_stream_map"]
-
+
if len(html) == 0 and
pl_obj["args"].has_key("url_encoded_fmt_stream_map"):
html =
urllib.unquote(pl_obj["args"]["url_encoded_fmt_stream_map"])
-
+
if len(html) == 0 and pl_obj["args"].has_key("fmt_url_map"):
- html = pl_obj["args"]["fmt_url_map"]
-
+ html = pl_obj["args"]["fmt_url_map"]
+
html = urllib.unquote_plus(html)
-
+
if pl_obj["args"].has_key("liveplayback_module"):
video["live_play"] = "true"
-
+
fmt_url_map = [html]
if html.find("|") > -1:
fmt_url_map = html.split('|')
@@ -101,6 +101,11 @@ class YouTubePlayer:
if len(fmt_url_map) > 0:
for index, fmt_url in enumerate(fmt_url_map):
+ if fmt_url.find("&url") > -1:
+ fmt_url = fmt_url.split("&url")
+ fmt_url_map += [fmt_url[1]]
+ fmt_url = fmt_url[0]
+
if (len(fmt_url) > 7 and fmt_url.find("&") > 7):
quality = "5"
final_url = fmt_url.replace(" ",
"%20").replace("url=", "")
@@ -124,7 +129,6 @@ class YouTubePlayer:
if final_url.find("&type") > 0:
final_url =
final_url[:final_url.find("&type")]
-
if
self.__settings__.getSetting("preferred") == "true":
pos = final_url.find("://")
fpos =
final_url.find("fallback_host")
@@ -135,7 +139,6 @@ class YouTubePlayer:
fmt_fallback =
final_url[fpos + 14:]
if
fmt_fallback.find("&") > -1:
fmt_fallback =
fmt_fallback[:fmt_fallback.find("&")]
- #print self.__plugin__
+ " Swapping cached host [%s] and fallback host [%s] " % ( host, fmt_fallback )
final_url =
final_url.replace(host, fmt_fallback)
final_url =
final_url.replace("fallback_host=" + fmt_fallback, "fallback_host=" + host)
@@ -268,14 +271,11 @@ class YouTubePlayer:
return (video, status)
def _convertFlashVars(self, html):
- #print self.__plugin__ + " _convertFlashVars : " + repr(html)
obj = { "PLAYER_CONFIG": { "args": {} } }
temp = html.split("&")
- print self.__plugin__ + " _convertFlashVars : " + str(len(temp))
for item in temp:
it = item.split("=")
obj["PLAYER_CONFIG"]["args"][it[0]] =
urllib.unquote_plus(it[1])
- #print self.__plugin__ + " _convertFlashVars done : " +
repr(obj)
return obj
def _getVideoLinks(self, video, params):
@@ -293,7 +293,7 @@ class YouTubePlayer:
data = result.find("PLAYER_CONFIG")
if data > -1:
data = result.rfind("yt.setConfig", 0, data)
- data =
re.compile('yt.setConfig\((.*?PLAYER_CONFIG.*?)\)').findall(result[data:].replace("\n",
""))
+ data =
re.compile('yt.setConfig\((.*?PLAYER_CONFIG.*?)\);').findall(result[data:].replace("\n",
""))
if len(data) > 0:
player_object =
json.loads(data[0].replace('\'PLAYER_CONFIG\'', '"PLAYER_CONFIG"'))
else:
diff --git a/plugin.video.youtube/YouTubeScraperCore.py
b/plugin.video.youtube/YouTubeScraperCore.py
index 6ed8488..85f3df9 100644
--- a/plugin.video.youtube/YouTubeScraperCore.py
+++ b/plugin.video.youtube/YouTubeScraperCore.py
@@ -518,7 +518,7 @@ class YouTubeScraperCore:
title = category.div.findNextSibling(name="div")
title = title.h2.contents[0].strip()
item['Title'] = title
- cat = cat.replace("/movies/", "")
+ cat = cat.replace("/movies/",
"").replace("/movies", "")
cat = urllib.quote_plus(cat)
item['category'] = cat
item['scraper'] = "movies"
diff --git a/plugin.video.youtube/addon.xml b/plugin.video.youtube/addon.xml
index d819872..6becd62 100644
--- a/plugin.video.youtube/addon.xml
+++ b/plugin.video.youtube/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.youtube"
name="YouTube"
- version="2.1.0"
+ version="2.1.2"
provider-name="TheCollective">
<requires>
<import addon="xbmc.python" version="1.0"/>
diff --git a/plugin.video.youtube/changelog.txt
b/plugin.video.youtube/changelog.txt
index af540c7..d858b88 100644
--- a/plugin.video.youtube/changelog.txt
+++ b/plugin.video.youtube/changelog.txt
@@ -7,14 +7,17 @@
- [YOUTUBE] Can't delete favorites (YouTube gives video id, not favorite id).
- Download of rtmpe streams not supported.
-[B]Version 2.2.4[/B]
-- Verfied Compatibility with Eden - pre and submitted to repo.
+[B]Version 2.1.2[/B]
+- Fixed problem with playback caused by bad regex.
+- Disabled most of the scrapers since they didn't work, working versions can
be found in the current beta
+- Disabled plugin setting list content to movies
+- Fixed login.
[B]Version 2.1.0[/B]
-- Fixed YouTube playback and downloading by backporting code from trunk
+- Fixed YouTube playback and downloading by back-porting code from trunk
[B]Version 2.0.5[/B]
-- Fixed http login was broken, somtimes preventing video scrapeing
+- Fixed http login was broken, sometimes preventing video scraping
- Fixed Show Scraper was broken due to recent YouTube site changes
- Fixed Added dutch translations properly
- Changed Name string from Holland to The Netherlands (thanks to Syrion for
pointing it out)
diff --git a/plugin.video.youtube/default.py b/plugin.video.youtube/default.py
index a614062..856ceb3 100644
--- a/plugin.video.youtube/default.py
+++ b/plugin.video.youtube/default.py
@@ -16,10 +16,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
-import sys, xbmc, xbmcaddon
+import sys, xbmc, xbmcaddon, cookielib, urllib2
# plugin constants
-__version__ = "2.0.5"
+__version__ = "2.1.2"
__plugin__ = "YouTube-" + __version__
__author__ = "TheCollective"
__url__ = "www.xbmc.com"
@@ -27,6 +27,10 @@ __settings__ = xbmcaddon.Addon(id='plugin.video.youtube')
__language__ = __settings__.getLocalizedString
__dbg__ = __settings__.getSetting( "debug" ) == "true"
+cookiejar = cookielib.LWPCookieJar()
+opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
+urllib2.install_opener(opener)
+
if (__name__ == "__main__" ):
if __dbg__:
print __plugin__ + " ARGV: " + repr(sys.argv)
-----------------------------------------------------------------------
Summary of changes:
plugin.video.youtube/YouTubeCore.py | 342 ++-----------
plugin.video.youtube/YouTubeLogin.py | 800 ++++++++++++++++++++++++++++
plugin.video.youtube/YouTubeNavigation.py | 55 +-
plugin.video.youtube/YouTubePlayer.py | 26 +-
plugin.video.youtube/YouTubeScraperCore.py | 2 +-
plugin.video.youtube/addon.xml | 2 +-
plugin.video.youtube/changelog.txt | 11 +-
plugin.video.youtube/default.py | 8 +-
8 files changed, 895 insertions(+), 351 deletions(-)
create mode 100755 plugin.video.youtube/YouTubeLogin.py
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
The demand for IT networking professionals continues to grow, and the
demand for specialized networking skills is growing even more rapidly.
Take a complimentary Learning@Cisco Self-Assessment and learn
about Cisco certifications, training, and career opportunities.
http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons