mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-04-14 19:14:51 +09:00
corrected HypemIE and added tests for hypem.com
This commit is contained in:
parent
40e4fcf910
commit
90e48f573d
@ -491,5 +491,14 @@
|
|||||||
"info_dict":{
|
"info_dict":{
|
||||||
"title":"FemaleAgent Shy beauty takes the bait"
|
"title":"FemaleAgent Shy beauty takes the bait"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Hypem",
|
||||||
|
"url": "http://hypem.com/track/1v6ga/BODYWORK+-+TAME",
|
||||||
|
"file": "1v6ga.mp3",
|
||||||
|
"md5": "b9cc91b5af8995e9f0c1cee04c575828",
|
||||||
|
"info_dict":{
|
||||||
|
"title":"TAME"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -19,6 +19,7 @@ import operator
|
|||||||
import hashlib
|
import hashlib
|
||||||
import binascii
|
import binascii
|
||||||
import urllib
|
import urllib
|
||||||
|
import urllib2
|
||||||
|
|
||||||
from .utils import *
|
from .utils import *
|
||||||
|
|
||||||
@ -4487,22 +4488,17 @@ class HypemIE(InfoExtractor):
|
|||||||
"""Information Extractor for hypem"""
|
"""Information Extractor for hypem"""
|
||||||
_VALID_URL = r'(?:http://)?(?:www\.)?hypem\.com/track/([^/]+)/([^/]+)'
|
_VALID_URL = r'(?:http://)?(?:www\.)?hypem\.com/track/([^/]+)/([^/]+)'
|
||||||
|
|
||||||
def removeDisallowedFilenameChars(filename):
|
|
||||||
validFilenameChars = "-_.() %s%s" % (string.ascii_letters, string.digits)
|
|
||||||
cleanedFilename = unicodedata.normalize('NFKD', filename).encode('ASCII', 'ignore')
|
|
||||||
return ''.join(c for c in cleanedFilename if c in validFilenameChars)
|
|
||||||
|
|
||||||
def _real_extract(self,url):
|
def _real_extract(self,url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
if mobj is None:
|
if mobj is None:
|
||||||
raise ExtractorError(u'Invalid URL: %s' % url)
|
raise ExtractorError(u'Invalid URL: %s' % url)
|
||||||
data = {'ax':1 ,
|
data = {'ax':1 ,
|
||||||
'ts': time()
|
'ts': time.time()
|
||||||
}
|
}
|
||||||
data_encoded = urllib.urlencode(data)
|
data_encoded = urllib.urlencode(data)
|
||||||
complete_url = url + "?"+data_encoded
|
complete_url = url + "?"+data_encoded
|
||||||
request = urllib2.Request(complete_url)
|
request = compat_urllib_request.Request(complete_url)
|
||||||
response = urllib2.urlopen(request)
|
response = compat_urllib_request.urlopen(request)
|
||||||
#save our cookie
|
#save our cookie
|
||||||
cookie = response.headers.get('Set-Cookie')
|
cookie = response.headers.get('Set-Cookie')
|
||||||
#grab the HTML
|
#grab the HTML
|
||||||
@ -4523,15 +4519,16 @@ class HypemIE(InfoExtractor):
|
|||||||
for track in tracks:
|
for track in tracks:
|
||||||
key = track[u"key"]
|
key = track[u"key"]
|
||||||
id = track[u"id"]
|
id = track[u"id"]
|
||||||
artist = removeDisallowedFilenameChars(track[u"artist"])
|
artist = track[u"artist"]
|
||||||
title = removeDisallowedFilenameChars(track[u"song"])
|
title = track[u"song"]
|
||||||
type = track[u"type"]
|
type = track[u"type"]
|
||||||
if type is False:
|
if type is False:
|
||||||
continue
|
continue
|
||||||
serve_url = "http://hypem.com/serve/source/{}/{}".format(id, key)
|
serve_url = "http://hypem.com/serve/source/%s/%s"%(str(id), str(key))
|
||||||
request = urllib2.Request(serve_url, "" , {'Content-Type': 'application/json'})
|
self.report_extraction(id)
|
||||||
|
request = compat_urllib_request.Request(serve_url, "" , {'Content-Type': 'application/json'})
|
||||||
request.add_header('cookie', cookie)
|
request.add_header('cookie', cookie)
|
||||||
response = urllib2.urlopen(request)
|
response = compat_urllib_request.urlopen(request)
|
||||||
song_data_json = response.read()
|
song_data_json = response.read()
|
||||||
response.close()
|
response.close()
|
||||||
song_data = json.loads(song_data_json)
|
song_data = json.loads(song_data_json)
|
||||||
@ -4544,6 +4541,7 @@ class HypemIE(InfoExtractor):
|
|||||||
'artist': artist,
|
'artist': artist,
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
|
||||||
def gen_extractors():
|
def gen_extractors():
|
||||||
""" Return a list of an instance of every supported extractor.
|
""" Return a list of an instance of every supported extractor.
|
||||||
The order does matter; the first extractor matched is the one handling the URL.
|
The order does matter; the first extractor matched is the one handling the URL.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user