fix dailymotion (play still doesn't work)
It fixes search and get video url (code from youtube-dl) It isn't possible to play because it is necessary to give cookies to player
This commit is contained in:
parent
f8a6da674c
commit
5dd502bfe5
1 changed files with 18 additions and 23 deletions
|
|
@ -17,8 +17,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from weboob.tools.json import json
|
||||||
import datetime
|
import datetime
|
||||||
import urllib
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from weboob.tools.capabilities.thumbnail import Thumbnail
|
from weboob.tools.capabilities.thumbnail import Thumbnail
|
||||||
|
|
@ -70,10 +70,6 @@ class IndexPage(BasePage):
|
||||||
url = url.replace('jpeg_preview_medium.jpg', 'jpeg_preview_large.jpg')
|
url = url.replace('jpeg_preview_medium.jpg', 'jpeg_preview_large.jpg')
|
||||||
video.thumbnail = Thumbnail(unicode(url))
|
video.thumbnail = Thumbnail(unicode(url))
|
||||||
|
|
||||||
rating_div = self.parser.select(div, 'div.small_stars', 1)
|
|
||||||
video.rating_max = self.get_rate(rating_div)
|
|
||||||
video.rating = self.get_rate(rating_div.find('div'))
|
|
||||||
|
|
||||||
video.set_empty_fields(NotAvailable, ('url',))
|
video.set_empty_fields(NotAvailable, ('url',))
|
||||||
yield video
|
yield video
|
||||||
|
|
||||||
|
|
@ -99,24 +95,23 @@ class VideoPage(BasePage):
|
||||||
video.description = html2text(self.parser.tostring(self.parser.select(div, 'div#video_description', 1))).strip() or unicode()
|
video.description = html2text(self.parser.tostring(self.parser.select(div, 'div#video_description', 1))).strip() or unicode()
|
||||||
except BrokenPageError:
|
except BrokenPageError:
|
||||||
video.description = u''
|
video.description = u''
|
||||||
for script in self.parser.select(self.document.getroot(), 'div.dmco_html'):
|
|
||||||
# TODO support videos from anyclip, cf http://www.dailymotion.com/video/xkyjiv for example
|
embed_page = self.browser.readurl('http://www.dailymotion.com/embed/video/%s' % video.id)
|
||||||
if 'id' in script.attrib and script.attrib['id'].startswith('container_player_') and \
|
|
||||||
script.find('script') is not None:
|
m = re.search('var info = ({.*?}),', embed_page)
|
||||||
text = script.find('script').text
|
if not m:
|
||||||
mobj = re.search(r'<param name="flashvars" value="(.*)"', text)
|
raise BrokenPageError('Unable to find information about video')
|
||||||
if mobj is None:
|
|
||||||
raise BrokenPageError('Unable to extract video url')
|
info = json.loads(m.group(1))
|
||||||
flashvars = urllib.unquote(mobj.group(1))
|
for key in ['stream_h264_hd1080_url','stream_h264_hd_url',
|
||||||
for key in ['hd1080URL', 'hd720URL', 'hqURL', 'sdURL', 'ldURL', 'video_url']:
|
'stream_h264_hq_url','stream_h264_url',
|
||||||
if key in flashvars:
|
'stream_h264_ld_url']:
|
||||||
|
if info.get(key):#key in info and info[key]:
|
||||||
max_quality = key
|
max_quality = key
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
mobj = re.search(r'"' + max_quality + r'":"(.+?)"', flashvars)
|
raise BrokenPageError(u'Unable to extract video URL')
|
||||||
if mobj is None:
|
video.url = info[max_quality]
|
||||||
raise BrokenPageError('Unable to extract video url')
|
|
||||||
video.url = urllib.unquote(mobj.group(1)).replace('\\/', '/')
|
|
||||||
|
|
||||||
video.set_empty_fields(NotAvailable)
|
video.set_empty_fields(NotAvailable)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue