mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
add support for Xiami
This commit is contained in:
parent
00f27681ca
commit
4d96d9aa59
@ -31,6 +31,7 @@ Fork me on GitHub: <https://github.com/soimort/you-get>
|
||||
* Sina (新浪视频) <http://video.sina.com.cn>
|
||||
* Sohu (搜狐视频) <http://tv.sohu.com>
|
||||
* 56 (56网) <http://www.56.com>
|
||||
* Xiam (虾米) <http://www.xiami.com>
|
||||
|
||||
## Dependencies
|
||||
|
||||
@ -222,6 +223,7 @@ You-Get基于优酷下载脚本[iambus/youku-lixian](https://github.com/iambus/y
|
||||
* 新浪视频 <http://video.sina.com.cn>
|
||||
* 搜狐视频 <http://tv.sohu.com>
|
||||
* 56网 <http://www.56.com>
|
||||
* 虾米 <http://www.xiami.com>
|
||||
|
||||
## 依赖
|
||||
|
||||
|
@ -34,6 +34,7 @@ Supported Sites (As of Now)
|
||||
* Sina (新浪视频) http://video.sina.com.cn
|
||||
* Sohu (搜狐视频) http://tv.sohu.com
|
||||
* 56 (56网) http://www.56.com
|
||||
* Xiam (虾米) http://www.xiami.com
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
@ -18,6 +18,7 @@ from .xtube import *
|
||||
from .tumblr import *
|
||||
from .vimeo import *
|
||||
from .w56 import *
|
||||
from .xiami import *
|
||||
from .yinyuetai import *
|
||||
from .youku import *
|
||||
from .youtube import *
|
||||
|
86
you_get/downloader/xiami.py
Executable file
86
you_get/downloader/xiami.py
Executable file
@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
__all__ = ['xiami_download']
|
||||
|
||||
from ..common import *
|
||||
|
||||
from xml.dom.minidom import parseString
|
||||
from urllib import parse
|
||||
|
||||
def location_dec(str):
|
||||
head = int(str[0])
|
||||
str = str[1:]
|
||||
rows = head
|
||||
cols = int(len(str)/rows) + 1
|
||||
|
||||
out = ""
|
||||
full_row = len(str) % head
|
||||
for c in range(cols):
|
||||
for r in range(rows):
|
||||
if c == (cols - 1) and r >= full_row:
|
||||
continue
|
||||
if r < full_row:
|
||||
char = str[r*cols+c]
|
||||
else:
|
||||
char = str[cols*full_row+(r-full_row)*(cols-1)+c]
|
||||
out += char
|
||||
return parse.unquote(out).replace("^", "0")
|
||||
|
||||
def xiami_download_song(sid, output_dir = '.', merge = True, info_only = False):
|
||||
xml = get_html('http://www.xiami.com/song/playlist/id/%s/object_name/default/object_id/0' % sid)
|
||||
doc = parseString(xml)
|
||||
i = doc.getElementsByTagName("track")[0]
|
||||
artist = i.getElementsByTagName("artist")[0].firstChild.nodeValue
|
||||
album_name = i.getElementsByTagName("album_name")[0].firstChild.nodeValue
|
||||
song_title = i.getElementsByTagName("title")[0].firstChild.nodeValue
|
||||
url = location_dec(i.getElementsByTagName("location")[0].firstChild.nodeValue)
|
||||
type, ext, size = url_info(url)
|
||||
download_urls([url], "%s - %s - %s" % (song_title, artist, album_name), ext, size, output_dir, merge = merge)
|
||||
|
||||
def xiami_download_showcollect(sid, output_dir = '.', merge = True, info_only = False):
|
||||
xml = get_html('http://www.xiami.com/song/playlist/id/%s/type/3' % sid)
|
||||
doc = parseString(xml)
|
||||
tracks = doc.getElementsByTagName("track")
|
||||
track_nr = 1
|
||||
for i in tracks:
|
||||
artist = i.getElementsByTagName("artist")[0].firstChild.nodeValue
|
||||
album_name = i.getElementsByTagName("album_name")[0].firstChild.nodeValue
|
||||
song_title = i.getElementsByTagName("title")[0].firstChild.nodeValue
|
||||
url = location_dec(i.getElementsByTagName("location")[0].firstChild.nodeValue)
|
||||
type, ext, size = url_info(url)
|
||||
download_urls([url], "%02d.%s - %s - %s" % (track_nr, song_title, artist, album_name), ext, size, output_dir, merge = merge)
|
||||
track_nr += 1
|
||||
|
||||
def xiami_download_album(sid, output_dir = '.', merge = True, info_only = False):
|
||||
xml = get_html('http://www.xiami.com/song/playlist/id/%s/type/1' % sid)
|
||||
album_name = r1(r'<album_name><!\[CDATA\[(.*)\]\]>', xml)
|
||||
doc = parseString(xml)
|
||||
tracks = doc.getElementsByTagName("track")
|
||||
track_nr = 1
|
||||
for i in tracks:
|
||||
song_title = i.getElementsByTagName("title")[0].firstChild.nodeValue
|
||||
url = location_dec(i.getElementsByTagName("location")[0].firstChild.nodeValue)
|
||||
type, ext, size = url_info(url)
|
||||
download_urls([url], "%s - %02d.%s" % (album_name, track_nr, song_title), ext, size, output_dir, merge = merge)
|
||||
track_nr += 1
|
||||
|
||||
def xiami_download(url, output_dir = '.', stream_type = None, merge = True, info_only = False):
|
||||
|
||||
if re.match(r'http://www.xiami.com/album/\d+', url):
|
||||
id = r1(r'http://www.xiami.com/album/(\d+)', url)
|
||||
return xiami_download_album(id, output_dir, merge, info_only)
|
||||
|
||||
if re.match(r'http://www.xiami.com/song/showcollect/id/\d+', url):
|
||||
id = r1(r'http://www.xiami.com/song/showcollect/id/(\d+)', url)
|
||||
return xiami_download_showcollect(id, output_dir, merge, info_only)
|
||||
|
||||
if re.match('http://www.xiami.com/song/\d+', url):
|
||||
id = r1(r'http://www.xiami.com/song/(\d+)', url)
|
||||
return xiami_download_song(id)
|
||||
|
||||
return None
|
||||
|
||||
site_info = "Xiami.com"
|
||||
download = xiami_download
|
||||
download_playlist = playlist_not_supported("xiami")
|
@ -39,6 +39,7 @@ def url_to_module(url):
|
||||
'xtube': xtube,
|
||||
'tumblr': tumblr,
|
||||
'vimeo': vimeo,
|
||||
'xiami': xiami,
|
||||
'yinyuetai': yinyuetai,
|
||||
'youku': youku,
|
||||
'youtube': youtube,
|
||||
|
Loading…
Reference in New Issue
Block a user