Skip to content

Commit

Permalink
fix ytflashplayer
Browse files Browse the repository at this point in the history
youtube change the page layout and now encodes the embed flash player element as javascript.
  • Loading branch information
charrea6 committed Apr 4, 2012
1 parent c6d3a24 commit d3b3cf9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/video/plugins/ytflashplayer.py
Expand Up @@ -31,6 +31,7 @@
import re
import socket
import urllib2
import json

from BeautifulSoup import BeautifulSoup
import urlparse
Expand All @@ -45,6 +46,7 @@
import util.httpserver
import util.webbrowser as webbrowser


from event import *

local_server = None
Expand Down Expand Up @@ -196,7 +198,17 @@ def get_html(self, url):
u.close()

soup = BeautifulSoup(yt_page)
embed = soup.find(id='movie_player')
embed = None
swf = ''
for e in soup.findAll('script'):
if str(e.text).find('var swf = ') != -1:
swf = e.text
break
if swf:
sq = swf.find('"')
eq = swf.rfind('"')
embed = json.loads(swf[sq:eq+1])

if embed is None:
print '%s: failed to movie_player element'
filename = url.replace('http://www.youtube.com/watch?v=', '')
Expand Down

0 comments on commit d3b3cf9

Please sign in to comment.