Skip to content

Commit

Permalink
add support for SoundCloud, fix #33
Browse files Browse the repository at this point in the history
  • Loading branch information
soimort committed Dec 9, 2012
1 parent 0d1d713 commit 311f5d1
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ _*/
*.download
*.cmt.*
*.3gp
*.asf
*.flv
*.mkv
*.mp3
*.mp4
*.mpg
*.ts
Expand Down
8 changes: 5 additions & 3 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
Changelog
=========

0.3dev-20121209
0.3dev-20121210
---------------

*Date: 2012-12-09*
*Date: 2012-12-10*

* YouTube: downloading the highest available quality now
* YouTube: downloading the highest available quality now.
* Add support for:
- SoundCloud

0.2.16
------
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Fork me on GitHub: <https://github.com/soimort/you-get>
* Vimeo <http://vimeo.com>
* Dailymotion <http://dailymotion.com>
* Google+ <http://plus.google.com>
* SoundCloud <http://soundcloud.com>
* Youku (优酷) <http://www.youku.com>
* Tudou (土豆) <http://www.tudou.com>
* YinYueTai (音悦台) <http://www.yinyuetai.com>
Expand Down Expand Up @@ -202,6 +203,7 @@ You-Get基于优酷下载脚本[iambus/youku-lixian](https://github.com/iambus/y
* Vimeo <http://vimeo.com>
* Dailymotion <http://dailymotion.com>
* Google+ <http://plus.google.com>
* SoundCloud <http://soundcloud.com>
* 优酷 <http://www.youku.com>
* 土豆 <http://www.tudou.com>
* 音悦台 <http://www.yinyuetai.com>
Expand Down
1 change: 1 addition & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Supported Sites (As of Now)
* Vimeo http://vimeo.com
* Dailymotion http://dailymotion.com
* Google+ http://plus.google.com
* SoundCloud http://soundcloud.com
* Youku (优酷) http://www.youku.com
* Tudou (土豆) http://www.tudou.com
* YinYueTai (音悦台) http://www.yinyuetai.com
Expand Down
14 changes: 12 additions & 2 deletions you_get/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def url_info(url, faker = False):
'video/mp4': 'mp4',
'video/MP2T': 'ts',
'video/webm': 'webm',
'video/x-flv': 'flv'
'video/x-flv': 'flv',
'video/x-ms-asf': 'asf',
'audio/mpeg': 'mp3'
}
if type in mapping:
ext = mapping[type]
Expand Down Expand Up @@ -355,7 +357,7 @@ def download_urls(urls, title, ext, total_size, output_dir = '.', refer = None,
print('Real URLs:\n', urls, '\n')
return

assert ext in ('3gp', 'flv', 'mp4', 'webm')
#assert ext in ('3gp', 'flv', 'mp4', 'webm')
if not total_size:
try:
total_size = urls_size(urls)
Expand Down Expand Up @@ -504,8 +506,12 @@ def f(*args, **kwargs):
def print_info(site_info, title, type, size):
if type in ['3gp']:
type = 'video/3gpp'
elif type in ['asf']:
type = 'video/x-ms-asf'
elif type in ['flv', 'f4v']:
type = 'video/x-flv'
elif type in ['mp3']:
type = 'audio/mpeg'
elif type in ['mp4']:
type = 'video/mp4'
elif type in ['ts']:
Expand All @@ -531,8 +537,12 @@ def print_info(site_info, title, type, size):
# type_info = "Matroska video (%s)" % type
#elif type in ['video/x-ms-wmv']:
# type_info = "Windows Media video (%s)" % type
elif type in ['video/x-ms-asf']:
type_info = "Advanced Systems Format (%s)" % type
#elif type in ['video/mpeg']:
# type_info = "MPEG video (%s)" % type
elif type in ['audio/mpeg']:
type_info = "MP3 (%s)" % type
else:
type_info = "Unknown type (%s)" % type

Expand Down
1 change: 1 addition & 0 deletions you_get/downloader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .qq import *
from .sina import *
from .sohu import *
from .soundcloud import *
from .tudou import *
from .vimeo import *
from .w56 import *
Expand Down
31 changes: 31 additions & 0 deletions you_get/downloader/soundcloud.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python

__all__ = ['soundcloud_download', 'soundcloud_download_by_id']

from ..common import *

def soundcloud_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False):
assert title

#if info["downloadable"]:
# url = 'https://api.soundcloud.com/tracks/' + id + '/download?client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
url = 'https://api.soundcloud.com/tracks/' + id + '/stream?client_id=b45b1aa10f1ac2941910a7f0d10f8e28'
assert url
type, ext, size = url_info(url)

print_info(site_info, title, type, size)
if not info_only:
download_urls([url], title, ext, size, output_dir, merge = merge)

def soundcloud_download(url, output_dir = '.', merge = True, info_only = False):
metadata = get_html('https://api.sndcdn.com/resolve.json?url=' + url + '&client_id=b45b1aa10f1ac2941910a7f0d10f8e28')
import json
info = json.loads(metadata)
title = info["title"]
id = str(info["id"])

soundcloud_download_by_id(id, title, output_dir, merge = merge, info_only = info_only)

site_info = "SoundCloud.com"
download = soundcloud_download
download_playlist = playlist_not_supported('soundcloud')
1 change: 1 addition & 0 deletions you_get/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def url_to_module(url):
'sina': sina,
'smgbb': bilibili,
'sohu': sohu,
'soundcloud': soundcloud,
'tudou': tudou,
'vimeo': vimeo,
'yinyuetai': yinyuetai,
Expand Down
4 changes: 2 additions & 2 deletions you_get/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python

__version__ = '0.3dev-20121209'
__date__ = '2012-12-09'
__version__ = '0.3dev-20121210'
__date__ = '2012-12-10'

0 comments on commit 311f5d1

Please sign in to comment.