mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
add suport for songtaste
This commit is contained in:
parent
3a3dd740f5
commit
f0a21e8ea5
4
.gitignore
vendored
4
.gitignore
vendored
@ -17,3 +17,7 @@ _*/
|
||||
*.mpg
|
||||
*.ts
|
||||
*.webm
|
||||
|
||||
*.DS_Store
|
||||
*.swp
|
||||
*~
|
||||
|
@ -57,6 +57,7 @@ def url_to_module(url):
|
||||
'youku': youku,
|
||||
'youtu': youtube,
|
||||
'youtube': youtube,
|
||||
'songtaste':songtaste,
|
||||
#TODO
|
||||
}
|
||||
if k in downloads:
|
||||
|
@ -35,3 +35,4 @@ from .baidu import *
|
||||
from .yinyuetai import *
|
||||
from .youku import *
|
||||
from .youtube import *
|
||||
from .songtaste import *
|
||||
|
44
src/you_get/downloader/songtaste.py
Normal file
44
src/you_get/downloader/songtaste.py
Normal file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__all__ = ['songtaste_download']
|
||||
|
||||
from ..common import *
|
||||
import urllib.error
|
||||
def songtaste_download(url, output_dir = '.', merge = True, info_only = False):
|
||||
|
||||
if re.match(r'http://www.songtaste.com/song/\d+', url):
|
||||
old_fake_headers = fake_headers
|
||||
id = r1(r'http://www.songtaste.com/song/(\d+)', url)
|
||||
player_url = 'http://www.songtaste.com/playmusic.php?song_id='+str(id)
|
||||
fake_headers['Referer'] = player_url
|
||||
html = get_response(player_url).data
|
||||
r = '''^WrtSongLine\((.*)\)'''
|
||||
|
||||
reg = re.compile(r , re.M)
|
||||
|
||||
m = reg.findall(html.decode('gbk'))
|
||||
l = m[0].replace('"', '').replace(' ', '').split(',')
|
||||
|
||||
title = l[2] + '-' + l[1]
|
||||
|
||||
for i in range(0, 10):
|
||||
real_url = l[5].replace('http://mg', 'http://m%d' % i)
|
||||
try:
|
||||
type, ext, size = url_info(real_url, True)
|
||||
except urllib.error.HTTPError as e:
|
||||
if 403 == e.code:
|
||||
continue
|
||||
else:
|
||||
raise e
|
||||
break
|
||||
|
||||
print_info(site_info, title, type, size)
|
||||
|
||||
if not info_only:
|
||||
download_urls([real_url], title, ext, size, output_dir, refer = url, merge = merge, faker = True)
|
||||
fake_hreaders = old_fake_headers
|
||||
|
||||
|
||||
site_info = "www.songtaste.com"
|
||||
download = songtaste_download
|
||||
download_playlist = playlist_not_supported('songtaste')
|
Loading…
Reference in New Issue
Block a user