mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2025-05-05 05:07:30 +00:00
Merge da6386f8f245ee160874159294cbc87c4b4407fb into 34554a7ad4186ad5f39d1b9903b8b619bd77bba1
This commit is contained in:
commit
b0719de04b
31
youtube-dl
31
youtube-dl
@ -39,6 +39,7 @@ import urllib
|
|||||||
import urllib2
|
import urllib2
|
||||||
import warnings
|
import warnings
|
||||||
import zlib
|
import zlib
|
||||||
|
import json
|
||||||
|
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
import ctypes
|
import ctypes
|
||||||
@ -1519,7 +1520,7 @@ class DailymotionIE(InfoExtractor):
|
|||||||
video_id = mobj.group(1)
|
video_id = mobj.group(1)
|
||||||
|
|
||||||
simple_title = mobj.group(2).decode('utf-8')
|
simple_title = mobj.group(2).decode('utf-8')
|
||||||
video_extension = 'flv'
|
video_extension = 'mp4'
|
||||||
|
|
||||||
# Retrieve video webpage to extract further information
|
# Retrieve video webpage to extract further information
|
||||||
request = urllib2.Request(url)
|
request = urllib2.Request(url)
|
||||||
@ -1531,16 +1532,31 @@ class DailymotionIE(InfoExtractor):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Extract URL, uploader and title from webpage
|
# Extract URL, uploader and title from webpage
|
||||||
|
# First we need to get the sequence urlencoded json variable
|
||||||
self.report_extraction(video_id)
|
self.report_extraction(video_id)
|
||||||
mobj = re.search(r'(?i)addVariable\(\"video\"\s*,\s*\"([^\"]*)\"\)', webpage)
|
mobj = re.search(r'(?i)addVariable\(\"sequence\"\s*,\s*\"([^\"]*)\"\)', webpage)
|
||||||
if mobj is None:
|
if mobj is None:
|
||||||
self._downloader.trouble(u'ERROR: unable to extract media URL')
|
self._downloader.trouble(u'ERROR: unable to extract media URL')
|
||||||
return
|
return
|
||||||
mediaURL = urllib.unquote(mobj.group(1))
|
|
||||||
|
|
||||||
# if needed add http://www.dailymotion.com/ if relative URL
|
# if needed add http://www.dailymotion.com/ if relative URL
|
||||||
|
sequenceJsonContent = urllib.unquote_plus(mobj.group(1))
|
||||||
|
|
||||||
video_url = mediaURL
|
# JSON does not suppot escaping of '.
|
||||||
|
# Replace every \' by a ' in the JSON string
|
||||||
|
sequenceJsonContent = sequenceJsonContent.replace("\\'", "'")
|
||||||
|
|
||||||
|
# Build the JSON object based on the string
|
||||||
|
try:
|
||||||
|
sequenceJson = json.loads(sequenceJsonContent)
|
||||||
|
except:
|
||||||
|
self._downloader.trouble(u'ERROR: unable to extract media URL (Bad JSON encoding)')
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
video_url = sequenceJson[0]["layerList"][0]["sequenceList"][1]["layerList"][2]["param"]["videoPluginParameters"]["hqURL"]
|
||||||
|
except:
|
||||||
|
self._downloader.trouble(u'ERROR: unable to extract media URL (Unable to find the URL)')
|
||||||
|
return
|
||||||
|
|
||||||
# '<meta\s+name="title"\s+content="Dailymotion\s*[:\-]\s*(.*?)"\s*\/\s*>'
|
# '<meta\s+name="title"\s+content="Dailymotion\s*[:\-]\s*(.*?)"\s*\/\s*>'
|
||||||
mobj = re.search(r'(?im)<title>Dailymotion\s*[\-:]\s*(.+?)</title>', webpage)
|
mobj = re.search(r'(?im)<title>Dailymotion\s*[\-:]\s*(.+?)</title>', webpage)
|
||||||
@ -1550,11 +1566,12 @@ class DailymotionIE(InfoExtractor):
|
|||||||
video_title = mobj.group(1).decode('utf-8')
|
video_title = mobj.group(1).decode('utf-8')
|
||||||
video_title = sanitize_title(video_title)
|
video_title = sanitize_title(video_title)
|
||||||
|
|
||||||
mobj = re.search(r'(?im)<Attribute name="owner">(.+?)</Attribute>', webpage)
|
# Extract the video uploader nickname from the sequence JSON
|
||||||
if mobj is None:
|
try:
|
||||||
|
video_uploader = sequenceJson[0]["layerList"][0]["sequenceList"][1]["layerList"][0]["param"]["metadata"]["uploader"]
|
||||||
|
except:
|
||||||
self._downloader.trouble(u'ERROR: unable to extract uploader nickname')
|
self._downloader.trouble(u'ERROR: unable to extract uploader nickname')
|
||||||
return
|
return
|
||||||
video_uploader = mobj.group(1)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Process video information
|
# Process video information
|
||||||
|
Loading…
x
Reference in New Issue
Block a user