The branch, dharma has been updated
via 360944f000d5d520a45057760e36c13767e3efa5 (commit)
from 2d313400c70f65581f8810b3cd016ef88225c9bd (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=360944f000d5d520a45057760e36c13767e3efa5
commit 360944f000d5d520a45057760e36c13767e3efa5
Author: spiff <[email protected]>
Date: Thu Aug 4 10:52:08 2011 +0200
[plugin.video.youtube] updated to version 2.1.0
diff --git a/plugin.video.youtube/YouTubeCore.py
b/plugin.video.youtube/YouTubeCore.py
index 08b53c4..944ecd7 100755
--- a/plugin.video.youtube/YouTubeCore.py
+++ b/plugin.video.youtube/YouTubeCore.py
@@ -402,150 +402,6 @@ class YouTubeCore(object):
print self.__plugin__ + " downloadVideo done"
return ( video, 200 )
- def construct_video_url(self, params, encoding = 'utf-8', download =
False):
- get = params.get
- if ( not get("videoid") ):
- return ( "", 200)
-
- videoid = get("videoid")
-
- if self.__dbg__:
- print self.__plugin__ + " construct_video_url : " +
repr(videoid)
-
- video = self._get_details(videoid)
-
- if not video:
- if self.__dbg__:
- print self.__plugin__ + " construct_video_url
failed because of missing video from _get_details"
- return ( "", 500 )
-
- if ( 'apierror' in video ):
- if self.__dbg__:
- print self.__plugin__ + " construct_video_url,
got apierror: " + video['apierror']
- return (video['apierror'], 303)
-
- if download:
- hd_quality = int(self.__settings__.getSetting(
"hd_videos_download" ))
- if ( hd_quality == 0 ):
- hd_quality = int(self.__settings__.getSetting(
"hd_videos" ))
- else:
- hd_quality -= 1
- else:
- if (not get("quality")):
- hd_quality = int(self.__settings__.getSetting(
"hd_videos" ))
- else:
- if (get("quality") == "1080p"):
- hd_quality = 2
- elif (get("quality") == "720p"):
- hd_quality = 1
- else:
- hd_quality = 0
-
- try:
- (fmtSource, swfConfig, video['stream_map']) =
self._extractVariables(videoid)
-
- if ( not fmtSource ):
- if self.__dbg__:
- print self.__plugin__ + "
construct_video_url Hopefully this extra if check is now legacy THIS SHOULD NOT
HAPPEN ANYMORE"
- return ( "", 500 )
-
- if ( video['stream_map'] == 303 ):
- return (fmtSource, 303)
-
- fmt_url_map =
urllib.unquote_plus(fmtSource[0]).split('|')
- links = {};
- video_url = False
-
- print self.__plugin__ + " construct_video_url:
stream_map : " + video['stream_map']
- if (video['stream_map'] == 'True'):
- if self.__dbg__:
- print self.__plugin__ + "
construct_video_url: stream map"
-
- for fmt_url in fmt_url_map:
- if self.__dbg__:
- print self.__plugin__ + "
construct_video_url: fmt_url : " + repr(fmt_url)
-
- if (len(fmt_url) > 7 and
fmt_url.find(":\\/\\/") > 0):
- if (fmt_url.rfind(',') >
fmt_url.rfind('\/id\/')):
- final_url =
fmt_url[:fmt_url.rfind(',')]
- final_url =
final_url.replace('\u0026','&')
- if
(final_url.rfind('\/itag\/') > 0):
- quality =
final_url[final_url.rfind('\/itag\/') + 8:]
- else :
- quality = "5"
- links[int(quality)] =
final_url.replace('\/','/')
- else :
- final_url = fmt_url
- final_url =
final_url.replace('\u0026','&')
- if
(final_url.rfind('\/itag\/') > 0):
- quality =
final_url[final_url.rfind('\/itag\/') + 8:]
- else :
- quality = "5"
- links[int(quality)] =
final_url.replace('\/','/')
-
- else:
- if self.__dbg__:
- print self.__plugin__ + "
construct_video_url: non stream map"
- for fmt_url in fmt_url_map:
- if (len(fmt_url) > 7):
- if (fmt_url.rfind(',') >
fmt_url.rfind('&id=')):
- final_url =
fmt_url[:fmt_url.rfind(',')]
- final_url =
final_url.replace('\u0026','&')
- if
(final_url.rfind('itag=') > 0):
- quality =
final_url[final_url.rfind('itag=') + 5:]
- quality =
quality[:quality.find('&')]
- else:
- quality = "5"
- links[int(quality)] =
final_url.replace('\/','/')
- else :
- final_url = fmt_url
- if
(final_url.rfind('itag=') > 0):
- quality =
final_url[final_url.rfind('itag=') + 5:]
- quality =
quality[:quality.find('&')]
- else :
- quality = "5"
- links[int(quality)] =
final_url.replace('\/','/')
-
- get = links.get
-
- # SD videos are default, but we go for the highest res
- if (get(35)):
- video_url = get(35)
- elif (get(34)):
- video_url = get(34)
- elif (get(18)):
- video_url = get(18)
- elif (get(5)):
- video_url = get(5)
-
- if (hd_quality > 0): #<-- 720p
- if (get(22)):
- video_url = get(22)
- if (hd_quality > 1): #<-- 1080p
- if (get(37)):
- video_url = get(37)
-
- if ( not video_url ):
- if self.__dbg__:
- print self.__plugin__ + "
construct_video_url failed, video_url not set"
- return (self.__language__(30607), 303)
-
- if (video['stream_map'] == 'True'):
- video['swf_config'] = swfConfig
-
- video['video_url'] = video_url;
-
- if self.__dbg__:
- print self.__plugin__ + " construct_video_url
done"
-
- return (video, 200);
- except:
- if self.__dbg__:
- print self.__plugin__ + " construct_video_url
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 ( "", 500 )
-
-
def arrayToPipe(self, input):
pipedItems = ""
for item in input:
diff --git a/plugin.video.youtube/YouTubeNavigation.py
b/plugin.video.youtube/YouTubeNavigation.py
index e190f42..99a0791 100644
--- a/plugin.video.youtube/YouTubeNavigation.py
+++ b/plugin.video.youtube/YouTubeNavigation.py
@@ -23,11 +23,13 @@ import xbmcgui
import xbmcplugin
import urllib
import YouTubeCore
+import YouTubePlayer
import YouTubeScraperCore
-core = YouTubeCore.YouTubeCore();
-scraper = YouTubeScraperCore.YouTubeScraperCore();
-
+core = YouTubeCore.YouTubeCore()
+scraper = YouTubeScraperCore.YouTubeScraperCore()
+player = YouTubePlayer.YouTubePlayer()
+
class YouTubeNavigation:
__settings__ = sys.modules[ "__main__" ].__settings__
__language__ = sys.modules[ "__main__" ].__language__
@@ -198,7 +200,7 @@ class YouTubeNavigation:
if (get("action") == "list_related"):
self.listRelated(params)
if (get("action") == "play_video"):
- self.playVideo(params)
+ player.playVideo(params)
if (get("action") == "change_subscription_view"):
self.changeSubscriptionView(params)
@@ -413,31 +415,7 @@ class YouTubeNavigation:
result = self.getUserInput(self.__language__(30518), '')
params["videoid"] = result
if (result):
- self.playVideo(params);
-
- def playVideo(self, params = {}):
- get = params.get
- (video, status) = core.construct_video_url(params);
-
- if status != 200:
- self.errorHandling(self.__language__(30603), video,
status)
- return False
-
- if ( 'swf_config' in video ):
- video['video_url'] += " swfurl=%s swfvfy=1" %
video['swf_config']
-
- video['video_url'] += " | " + core.USERAGENT
-
- listitem=xbmcgui.ListItem(label=video['Title'],
iconImage=video['thumbnail'], thumbnailImage=video['thumbnail'],
path=video['video_url']);
-
- listitem.setInfo(type='Video', infoLabels=video)
-
- if self.__dbg__:
- print self.__plugin__ + " - Playing video: " +
video['Title'] + " - " + get('videoid') + " - " + video['video_url']
-
- xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]),
succeeded=True, listitem=listitem)
-
- self.__settings__.setSetting( "vidstatus-" + video['videoid'],
"7" )
+ player.playVideo(params);
def downloadVideo(self, params = {}):
get = params.get
@@ -448,7 +426,7 @@ class YouTubeNavigation:
self.__settings__.openSettings()
path = self.__settings__.getSetting(
"downloadPath" )
- ( video, status ) = core.construct_video_url(params)
+ ( video, status ) = player.getVideoObject(params)
if status != 200:
if self.__dbg__:
diff --git a/plugin.video.youtube/YouTubeScraperCore.py
b/plugin.video.youtube/YouTubeScraperCore.py
index 7e5f34c..6ed8488 100644
--- a/plugin.video.youtube/YouTubeScraperCore.py
+++ b/plugin.video.youtube/YouTubeScraperCore.py
@@ -282,10 +282,12 @@ class YouTubeScraperCore:
list = SoupStrainer(name="div", attrs =
{"class":"popular-message"})
popular = BeautifulSoup(page, parseOnlyThese=list)
items = []
+
if (len(popular) > 0):
videos = self.urls["main"] + popular.a["onclick"]
- if (videos.find("([") > 0):
- videos = videos[videos.find("([") +
2:videos.rfind("])")]
+ videos = videos.replace(""",'"')
+ if (videos.find('"') > 0):
+ videos =
videos[videos.find('["')+2:videos.rfind("])")]
videos = videos.replace('"',"")
videos = videos.replace(" ","")
items = videos.split(",")
diff --git a/plugin.video.youtube/addon.xml b/plugin.video.youtube/addon.xml
index af6005c..d819872 100644
--- a/plugin.video.youtube/addon.xml
+++ b/plugin.video.youtube/addon.xml
@@ -1,11 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.youtube"
name="YouTube"
- version="2.0.5"
+ version="2.1.0"
provider-name="TheCollective">
<requires>
<import addon="xbmc.python" version="1.0"/>
<import addon="script.module.beautifulsoup" version="3.0.8"/>
+ <import addon="script.module.simplejson" version="2.0.10"/>
</requires>
<extension point="xbmc.python.pluginsource"
library="default.py">
diff --git a/plugin.video.youtube/changelog.txt
b/plugin.video.youtube/changelog.txt
index 87229fa..af540c7 100644
--- a/plugin.video.youtube/changelog.txt
+++ b/plugin.video.youtube/changelog.txt
@@ -10,6 +10,9 @@
[B]Version 2.2.4[/B]
- Verfied Compatibility with Eden - pre and submitted to repo.
+[B]Version 2.1.0[/B]
+- Fixed YouTube playback and downloading by backporting code from trunk
+
[B]Version 2.0.5[/B]
- Fixed http login was broken, somtimes preventing video scrapeing
- Fixed Show Scraper was broken due to recent YouTube site changes
-----------------------------------------------------------------------
Summary of changes:
plugin.video.youtube/YouTubeCore.py | 144 -----------
plugin.video.youtube/YouTubeNavigation.py | 38 +---
plugin.video.youtube/YouTubePlayer.py | 367 ++++++++++++++++++++++++++++
plugin.video.youtube/YouTubeScraperCore.py | 6 +-
plugin.video.youtube/addon.xml | 3 +-
plugin.video.youtube/changelog.txt | 3 +
6 files changed, 384 insertions(+), 177 deletions(-)
create mode 100755 plugin.video.youtube/YouTubePlayer.py
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons