Last active
July 23, 2017 09:42
-
-
Save kyujin-cho/b2b348a8984157c769a8b9ce2d98a141 to your computer and use it in GitHub Desktop.
Soundcloud Downloader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| import urllib.request | |
| import os | |
| import os.path | |
| import subprocess | |
| p = re.compile('https:\/\/.+') | |
| l = open('playlist.m3u8', 'r').read() | |
| result = p.findall(l) | |
| if not os.path.exists('output'): | |
| os.makedirs('output') | |
| i = 0 | |
| try: | |
| for file in result: | |
| i += 1 | |
| print('downloading #', i, 'of', len(result), '...') | |
| with open('output/' + str(i) + '.mp3', 'wb') as f: | |
| mp3 = urllib.request.urlopen(file) | |
| f.write(mp3.read()) | |
| except: | |
| print('M3U8 file too old! Try with a newer one.') | |
| exit() | |
| print('calling', ['mp3cat', '-o', 'output/result.mp3'] + ['output/' + str(j) + '.mp3' for j in range(1, i + 1)]) | |
| subprocess.call(['mp3cat', '-o', 'output/result.mp3'] + ['output/' + str(j) + '.mp3' for j in range(1, i + 1)]) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Developed for macOS/Linux
Prequisites
- mp3cat installed
How-to
1. Download m3u8 file from soundcloud page, save it as 'playlist.m3u8' and place it in the same folder of the script
2. Run script
3. Your file is in the
outputfolder, namedresult.mp3