GithubHelp home page GithubHelp logo

flyingrub / scdl Goto Github PK

View Code? Open in Web Editor NEW
3.1K 65.0 310.0 299 KB

Soundcloud Music Downloader

License: GNU General Public License v2.0

Python 100.00%
soundcloud-music-downloader python soundcloud music downloader

scdl's Introduction

Soundcloud Music Downloader

Description

This script is able to download music from SoundCloud and set id3tag to the downloaded music. Compatible with Windows, OS X, Linux.

System requirements

  • python3
  • ffmpeg

Installation Instructions

https://github.com/flyingrub/scdl/wiki/Installation-Instruction

Configuration

There is a configuration file left in ~/.config/scdl/scdl.cfg

Examples:

# Download track & repost of the user QUANTA
scdl -l https://soundcloud.com/quanta-uk -a

# Download likes of the user Blastoyz
scdl -l https://soundcloud.com/kobiblastoyz -f

# Download one track
scdl -l https://soundcloud.com/jumpstreetpsy/low-extender

# Download one playlist
scdl -l https://soundcloud.com/pandadub/sets/the-lost-ship

# Download only new tracks from a playlist
scdl -l https://soundcloud.com/pandadub/sets/the-lost-ship --download-archive archive.txt -c

# Sync playlist
scdl -l https://soundcloud.com/pandadub/sets/the-lost-ship --sync archive.txt

# Download your likes (with authentification token)
scdl me -f

Options:

-h --help                       Show this screen
--version                       Show version
-l [url]                        URL can be track/playlist/user
-n [maxtracks]                  Download the n last tracks of a playlist according to the creation date
-s                              Download the stream of a user (token needed)
-a                              Download all tracks of user (including reposts)
-t                              Download all uploads of a user (no reposts)
-f                              Download all favorites of a user
-C                              Download all commented by a user
-p                              Download all playlists of a user
-r                              Download all reposts of user
-c                              Continue if a downloaded file already exists
--force-metadata                This will set metadata on already downloaded track
-o [offset]                     Begin with a custom offset
--addtimestamp                  Add track creation timestamp to filename,
                                which allows for chronological sorting
--addtofile                     Add artist to filename if missing
--debug                         Set log level to DEBUG
--download-archive [file]       Keep track of track IDs in an archive file,
                                and skip already-downloaded files
--error                         Set log level to ERROR
--extract-artist                Set artist tag from title instead of username
--hide-progress                 Hide the wget progress bar
--hidewarnings                  Hide Warnings. (use with precaution)
--max-size [max-size]           Skip tracks larger than size (k/m/g)
--min-size [min-size]           Skip tracks smaller than size (k/m/g)
--no-playlist-folder            Download playlist tracks into main directory,
                                instead of making a playlist subfolder
--onlymp3                       Download only the streamable mp3 file,
                                even if track has a Downloadable file
--path [path]                   Use a custom path for downloaded files
--remove                        Remove any files not downloaded from execution
--sync [file]	                Compare an archive file to a playlist and downloads/removes any changed tracks
--flac                          Convert original files to .flac
--no-album-tag                  On some player track get the same cover art if from the same album, this prevent it
--original-art                  Download original cover art
--original-name                 Do not change name of original file downloads
--no-original                   Do not download original file; only mp3 or m4a
--only-original                 Only download songs with original file available
--name-format [format]          Specify the downloaded file name format
--playlist-name-format [format] Specify the downloaded file name format, if it is being downloaded as part of a playlist
--client-id [id]                Specify the client_id to use
--auth-token [token]            Specify the auth token to use
--overwrite                     Overwrite file if it already exists
--strict-playlist               Abort playlist downloading if one track fails to download

Features

  • Automatically detect the type of link provided
  • Download all songs from a user
  • Download all songs and reposts from a user
  • Download all songs from one playlist
  • Download all songs from all playlists from a user
  • Download all songs from a user's favorites
  • Download only new tracks from a list (playlist, favorites, etc.)
  • Sync Playlist
  • Set the tags with mutagen (Title / Artist / Album / Artwork)
  • Create playlist files when downloading a playlist

License

GPL v2, original author flyingrub

scdl's People

Contributors

7x11x13 avatar andreasnuesslein avatar crosp avatar davidfischer-ch avatar devalnor avatar e2del avatar gpchelkin avatar gs11 avatar hgabs avatar hunkyburrito avatar justintm avatar kellergoech avatar madssj avatar mc0ps avatar migperfer avatar nablaa avatar ontes avatar r00t- avatar redfast00 avatar romaniukvadim avatar rozzy avatar rpryzant avatar spicypenguin avatar spotlight0xff avatar strfox avatar thetechrobo avatar timgates42 avatar tpenguinltg avatar vboufleur avatar zunayed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scdl's Issues

401 error

Hi there - I recently was running scdl using this command:

scdl -l https://soundcloud.com/redbullmusicacademy/branko-eventually-feat-alex-rita-bison

And got this error - any ideas?

I am running version 1.1.0

Found a track
Traceback (most recent call last):
File "/usr/local/bin/scdl", line 9, in
load_entry_point('scdl==v1.1.0', 'console_scripts', 'scdl')()
File "/usr/local/lib/python3.4/dist-packages/scdl/scdl.py", line 113, in main
parse_url(arguments["-l"])
File "/usr/local/lib/python3.4/dist-packages/scdl/scdl.py", line 177, in parse_url
download_track(item)
File "/usr/local/lib/python3.4/dist-packages/scdl/scdl.py", line 351, in download_track
stream_url = client.get(track.stream_url, allow_redirects=False)
File "/usr/local/lib/python3.4/dist-packages/soundcloud/client.py", line 130, in _request
return wrapped_resource(make_request(method, url, kwargs))
File "/usr/local/lib/python3.4/dist-packages/soundcloud/request.py", line 135, in make_request
result.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 773, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized

Windows rename exception from specific characters

Looks like on Windows it throws an exception if the filename has certain characters in it. Specifically I get the error for a file with a question mark ? in it:

  File "c:\Python34\lib\shutil.py", line 522, in move
    os.rename(src, real_dst)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:\\Users\\myles\\Music\\SC\\download.8jmfxs16.tmp' -> 'MAYHEM_x_ANTISERUM_vs_GENT_x_JAWNS_-_WHERE_YOU_BEEN?.mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\Scripts\scdl-script.py", line 9, in <module>
    load_entry_point('scdl==v1.1.1', 'console_scripts', 'scdl')()
  File "c:\Python34\lib\site-packages\scdl\scdl.py", line 118, in main
    download_user_favorites(who_am_i())
  File "c:\Python34\lib\site-packages\scdl\scdl.py", line 290, in download_user_favorites
    download_track(track)
  File "c:\Python34\lib\site-packages\scdl\scdl.py", line 378, in download_track
    wget.download(url, filename)
  File "c:\Python34\lib\site-packages\wget.py", line 320, in download
    shutil.move(tmpfile, filename)
  File "c:\Python34\lib\shutil.py", line 534, in move
    copy2(src, real_dst)
  File "c:\Python34\lib\shutil.py", line 244, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "c:\Python34\lib\shutil.py", line 108, in copyfile
    with open(dst, 'wb') as fdst:
OSError: [Errno 22] Invalid argument: 'MAYHEM_x_ANTISERUM_vs_GENT_x_JAWNS_-_WHERE_YOU_BEEN?.mp3'

Not possible to install scdl

I tried installing scdl with the given insctructions (via pip), but there is an error, that occurs on my Windows 8 machine in the same fashion then on my Ubuntu 14.04 machine, so I am assuming it's an issue of the script:

C:\Users\Moritz>py -m pip install scdl
Downloading/unpacking scdl
Downloading scdl-v1.0.3.tar.gz
Running setup.py (path:C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz\scd
l\setup.py) egg_info for package scdl

Downloading/unpacking docopt (from scdl)
Downloading docopt-0.6.2.tar.gz
Running setup.py (path:C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz\doc
opt\setup.py) egg_info for package docopt

Downloading/unpacking soundcloud (from scdl)
Downloading soundcloud-0.4.1.tar.gz
Running setup.py (path:C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz\sou
ndcloud\setup.py) egg_info for package soundcloud

Downloading/unpacking wget (from scdl)
Downloading wget-2.2.tar.gz
Running setup.py (path:C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz\wge
t\setup.py) egg_info for package wget

Downloading/unpacking configparser (from scdl)
Downloading configparser-3.3.0r2.tar.gz
Running setup.py (path:C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz\con
figparser\setup.py) egg_info for package configparser
Traceback (most recent call last):
File "", line 3, in
File "C:\Python34\lib\site-packages\setuptools__init__.py", line 5, in
import distutils.core
File "C:\Python34\lib\distutils\core.py", line 18, in
from distutils.config import PyPIRCCommand
File "C:\Python34\lib\distutils\config.py", line 7, in
from configparser import ConfigParser
File "C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz\configparser\con
figparser.py", line 397
_KEYCRE = re.compile(ur"%(([^)]+))s")
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 3, in

File "C:\Python34\lib\site-packages\setuptools__init__.py", line 5, in

import distutils.core

File "C:\Python34\lib\distutils\core.py", line 18, in

from distutils.config import PyPIRCCommand

File "C:\Python34\lib\distutils\config.py", line 7, in

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
The pip.log file content:


C:\Python34\lib\site-packages\pip__main__.py run on 12/28/14 09:57:16
Downloading/unpacking scdl
Getting page https://pypi.python.org/simple/scdl/
URLs to search for versions for scdl:

SyntaxError: invalid syntax


Cleaning up...
Removing temporary dir C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz...
Command python setup.py egg_info failed with error code 1 in C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz\configparser
Exception information:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Python34\lib\site-packages\pip\req.py", line 1229, in prepare_files
req_to_install.run_egg_info()
File "C:\Python34\lib\site-packages\pip\req.py", line 325, in run_egg_info
command_desc='python setup.py egg_info')
File "C:\Python34\lib\site-packages\pip\util.py", line 697, in call_subprocess
% (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command python setup.py egg_info failed with error code 1 in C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz\configparser

from configparser import ConfigParser

File "C:\Users\Moritz\AppData\Local\Temp\pip_build_Moritz\configparser\configp
arser.py", line 397

_KEYCRE = re.compile(ur"%\(([^)]+)\)s")

                                     ^

SyntaxError: invalid syntax


Cleaning up...
Command python setup.py egg_info failed with error code 1 in C:\Users\Moritz\App
Data\Local\Temp\pip_build_Moritz\configparser
Storing debug log for failure in C:\Users\Moritz\pip\pip.log

In case this is about my environment, please apologize, and I would be glad if you can tell me what is wrong with it.

scdl.exe cannot access scdl.cfg

On Windows 8 scdl.exe cannot access scdl.cfg trough env variable $HOME as on windows env. variables are read with %% instead of $, so the path should be %HOME%/.config/scdl/scdl.cfg instead of $HOME/.config/scdl/scdl.cfg (adding HOME env. variable does not solve the issue). Altough the scdl.cfg is created while installing trough pip in the correct folder.

Installation failure - Invalid syntax

$ sudo pip3 install scdl

//////////////////////
Running setup.py (path:/tmp/pip_build_root/mutagen/setup.py) egg_info for package mutagen
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip_build_root/mutagen/setup.py", line 227, in
from mutagen import version_string
File "mutagen/init.py", line 23, in
from mutagen._util import MutagenError
File "mutagen/_util.py", line 463
if c == u"\x00":
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "/tmp/pip_build_root/mutagen/setup.py", line 227, in

from mutagen import version_string

File "mutagen/init.py", line 23, in

from mutagen._util import MutagenError

File "mutagen/_util.py", line 463

if c == u"\x00":

              ^

SyntaxError: invalid syntax
//////////////////////

Any help would be greatly appreciated!

Unable to install

I used the install command but the programm won't install. Invalid syntax?

pip3 install scdl
// also tried
sudo pip3 install scdl
Downloading/unpacking scdl
  Downloading scdl-0.9.tar.gz
  Running setup.py (path:/tmp/pip_build_root/scdl/setup.py) egg_info for package scdl

Downloading/unpacking docopt (from scdl)
  Downloading docopt-0.6.2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/docopt/setup.py) egg_info for package docopt

Downloading/unpacking soundcloud (from scdl)
  Downloading soundcloud-0.4.1.tar.gz
  Running setup.py (path:/tmp/pip_build_root/soundcloud/setup.py) egg_info for package soundcloud

Downloading/unpacking wget (from scdl)
  Downloading wget-2.2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/wget/setup.py) egg_info for package wget

Downloading/unpacking configparser (from scdl)
  Downloading configparser-3.3.0r2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/configparser/setup.py) egg_info for package configparser
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 5, in <module>
        import distutils.core
      File "/usr/lib/python3.4/distutils/core.py", line 18, in <module>
        from distutils.config import PyPIRCCommand
      File "/usr/lib/python3.4/distutils/config.py", line 7, in <module>
        from configparser import ConfigParser
      File "/tmp/pip_build_root/configparser/configparser.py", line 397
        _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                             ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 3, in <module>

  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 5, in <module>

    import distutils.core

  File "/usr/lib/python3.4/distutils/core.py", line 18, in <module>

    from distutils.config import PyPIRCCommand

  File "/usr/lib/python3.4/distutils/config.py", line 7, in <module>

    from configparser import ConfigParser

  File "/tmp/pip_build_root/configparser/configparser.py", line 397

    _KEYCRE = re.compile(ur"%\(([^)]+)\)s")

                                         ^

SyntaxError: invalid syntax

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/configparser
Storing debug log for failure in /home/philippe/.pip/pip.log

401 Client Error: Unauthorized

requests.exceptions.HTTPError: 401 Client Error: Unauthorized
as of today, this is what I'm getting for sets/tracks, win32, scdl v1.1.1

is this just me, or did they change something on their servers?

ImportError: No module named request

Hi, I get this error trying to run scdl:
Traceback (most recent call last):
File "/usr/bin/scdl", line 9, in
load_entry_point('scdl==v1.0.2', 'console_scripts', 'scdl')()
File "/usr/lib64/python2.7/site-packages/pkg_resources.py", line 353, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib64/python2.7/site-packages/pkg_resources.py", line 2321, in load_entry_point
return ep.load()
File "/usr/lib64/python2.7/site-packages/pkg_resources.py", line 2048, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "/usr/lib64/python2.7/site-packages/scdl/scdl.py", line 38, in
import urllib.request
ImportError: No module named request

Installed using "sudo pip install scdl". Using python 2.7, 3.3 and 3.4 on Gentoo.

Charachter Encoding Problem on Windows

As tracktitles often contain some fancy hip special chars scdl is not able to rename the downloaded file according to the title on soundcloud, as Windows filenames cannot contain this chars. So I am thinking about implementing a "special char elimination method", as the special chars can also cause problems when trying to set tags for the mp3. The method should be optional, as these problems seem not to occur on Unix based systems. What do you think about that?

Songtitles with "~" make scdl crash

OS: OSX 10.9

Song:
https://soundcloud.com/octobersveryown/drake-6-god?in=tommydehaas/sets/its-always-summer-in-miami

Title: Drake ~ 6 God (Prod. by Boi-1da & Syk Sense)

Result:
Track n°27
Traceback (most recent call last):
File "/usr/local/bin/scdl", line 9, in
load_entry_point('scdl==1.1.1', 'console_scripts', 'scdl')()
File "/usr/local/lib/python3.4/site-packages/scdl/scdl.py", line 113, in main
parse_url(arguments["-l"])
File "/usr/local/lib/python3.4/site-packages/scdl/scdl.py", line 180, in parse_url
download_playlist(item)
File "/usr/local/lib/python3.4/site-packages/scdl/scdl.py", line 324, in download_playlist
download_track(mp3_url, playlist.title)
File "/usr/local/lib/python3.4/site-packages/scdl/scdl.py", line 351, in download_track
stream_url = client.get(track.stream_url, allow_redirects=False)
File "/usr/local/lib/python3.4/site-packages/soundcloud/client.py", line 130, in _request
return wrapped_resource(make_request(method, url, kwargs))
File "/usr/local/lib/python3.4/site-packages/soundcloud/request.py", line 135, in make_request
result.raise_for_status()
File "/usr/local/lib/python3.4/site-packages/requests/models.py", line 831, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found

error in renaming file names

cannot download this file as an example :
https://soundcloud.com/radiobooom/yaad

Found a track
Downloading یـــــــــاد
Downloading the orginal file.
100% [..........................................................................] 6410120 / 6410120Traceback (most recent call last):
  File "/usr/lib/python3.4/shutil.py", line 522, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/home/sina/scdl/download.qsb5lwo6.tmp' -> "Ì@@@@@@@@@'/.mp3"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/scdl", line 9, in <module>
    load_entry_point('scdl==v1.3.2', 'console_scripts', 'scdl')()
  File "/usr/local/lib/python3.4/dist-packages/scdl/scdl.py", line 115, in main
    parse_url(arguments["-l"])
  File "/usr/local/lib/python3.4/dist-packages/scdl/scdl.py", line 179, in parse_url
    download_track(item)
  File "/usr/local/lib/python3.4/dist-packages/scdl/scdl.py", line 398, in download_track
    wget.download(url, filename)
  File "/usr/local/lib/python3.4/dist-packages/wget.py", line 320, in download
    shutil.move(tmpfile, filename)
  File "/usr/lib/python3.4/shutil.py", line 534, in move
    copy2(src, real_dst)
  File "/usr/lib/python3.4/shutil.py", line 244, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.4/shutil.py", line 108, in copyfile
    with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: "Ì@@@@@@@@@'/.mp3"

Error with <offset> argument

$ scdl -l https://soundcloud.com/beatsbyesta/cant-waitft-spzrkt results in:

Soundcloud Downloader
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.4/bin/scdl", line 9, in
load_entry_point('scdl==v1.0.2', 'console_scripts', 'scdl')()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/scdl-v1.0.2-py3.4.egg/scdl/scdl.py", line 63, in main
KeyError: ''

Run as deamon?

Hey there - I want to combine your amazing application with piMusicBox.

Ultimately I would like to run scdl as a daemon which is always checking to see if a user (me) has any new "liked" tracks on my soundcloud and then it grabs them and puts it into a folder which PiMusicBox will grab and add to a playlist.

What would I need to do to run your app as a daemon?

would it be possible to run multiple instances if I wanted it to monitor several soundcloud users/tokens at the same time?

401 Client Error

More than one url show this message to me
it's new issue :(

Error resolving url, retrying...
Could not resolve url
401 Client Error: Unauthorized

Offset counter not properly updating in download_user_favorites

I modified the download_user_favorites to properly handle the offset counter, it might be possible to to clean up the code and remove my bs junk to utilize it properly? Perhaps
it was an issue solely on my rig (essentially after the first 10 tracks were downloaded the offset should have incremented and the list renew to the next 10 entries however instead it just looped at the original offset indefinitely).

def download_user_favorites(user):
    """
    Find tracks in user favorites
    """
    global offset
    count = 0
    favorites = client.get('/users/' + str(user.id) + '/favorites', limit=10, offset=offset)
    for track in favorites:
        if count<10:
            for track in favorites:
                count += 1
                print("")
                print('Favorite n°%d' % (count))
                download_track(track)
        else:    
            global offset
            offset = offset+10
            print('offset = %d' % (offset))
            count = 0
            favorites = client.get('/users/' + str(user.id) + '/favorites', limit=10, offset=offset)
    print('All users favorites downloaded!')

Also have you guys considered setting the limit higher and pushing up the offset counter loop? For users with more tracks or favorites it might help :)
Aside from that, I'm interested in contributing once I finish up finals here, especially with the mutagen tagging, but I'm also new to this place, so hopefully I'm not offending when I ask if it's possible to help?

AttributeError: 'ResourceList' object has no attribute 'kind'

command executed: python3 /usr/bin/scdl -l "https://soundcloud.com/syphoxy/likes"
command output:

Traceback (most recent call last):
  File "/usr/bin/scdl", line 9, in <module>
    load_entry_point('scdl==v1.0.6', 'console_scripts', 'scdl')()
  File "/usr/lib/python3.3/site-packages/scdl/scdl.py", line 87, in main
    parse_url(arguments["-l"])
  File "/usr/lib/python3.3/site-packages/scdl/scdl.py", line 146, in parse_url
    elif item.kind == 'track':
AttributeError: 'ResourceList' object has no attribute 'kind'

I just installed today via sudo python3-pip install scdl so it should be most up to date. not sure how to resolve this issue.

I'm not sure what the relevant information is to troubleshoot this issue. feel free to bug me about my system installation. for reference, it is Fedora 20.

error when installing

pip3 install scdl

Downloading/unpacking scdl
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/idna.py", line 165, in encode
    raise UnicodeError("label empty or too long")
UnicodeError: label empty or too long

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/commands/install.py", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/req.py", line 1177, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/index.py", line 194, in find_requirement
    page = self._get_page(main_index_url, req)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/index.py", line 568, in _get_page
    session=self.session,
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/index.py", line 670, in get_page
    resp = session.get(url, headers={"Accept": "text/html"})
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/_vendor/requests/sessions.py", line 468, in get
    return self.request('GET', url, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/download.py", line 237, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/_vendor/requests/sessions.py", line 429, in request
    env_proxies = get_environ_proxies(url) or {}
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/_vendor/requests/utils.py", line 516, in get_environ_proxies
    if should_bypass_proxies(url):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip/_vendor/requests/utils.py", line 505, in should_bypass_proxies
    bypass = proxy_bypass(netloc)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 2446, in proxy_bypass
    return proxy_bypass_macosx_sysconf(host)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 2430, in proxy_bypass_macosx_sysconf
    return _proxy_bypass_macosx_sysconf(host, proxy_settings)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 2403, in _proxy_bypass_macosx_sysconf
    hostIP = socket.gethostbyname(hostonly)
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)

Urllib2 doesn't exist in python3

I don't know how you possibly successfully run this script with python3 on your machine, because it tries to import urllib2 which doesn't exist in python 3.0 and above. urllib2 has been moved to urllib.request.

For example, this is what's said on the python wiki: https://docs.python.org/2/library/urllib2.html

Note The urllib2 module has been split across several modules in Python 3 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.

But like i said, works flawlessly when i change line 28 from "import urllib2" to "import urllib.request"
I am using python 3.4.2 on linux 3.17.

Make code DRY

Don't use many time same code but make an utility function.
For example, client.get is called many times with same pattern.

[song] is not streamable

Here are some examples that do not work

scdl -l https://soundcloud.com/seven-lions/seven-lions-with-myon-and
scdl -l https://soundcloud.com/serious-url/sceptics-club-mix
scdl -l https://soundcloud.com/zedd/alive

Is this an API limitation? Or what is causing it?
Out of about 25 tracks, 3 of them were unable to be downloaded because of this.
Why isn't the stream url available on some songs?
https://github.com/flyingrub/scdl/blob/master/scdl/scdl.py#L272

UnicodeEncodeError: 'charmap' codec can't encode ... character maps to <undefined>

scdl

Traceback (most recent call last):
File "scdl.py", line 408, in
main()
File "scdl.py", line 87, in main
parse_url(arguments["-l"])
File "scdl.py", line 160, in parse_url
download_user_tracks(item)
File "scdl.py", line 228, in download_user_tracks
download_track(track)
File "scdl.py", line 322, in download_track
print("Downloading " + title)
File "C:\Python34\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 12-18: character maps to

I've tried downloading using the single and all-songs method to download. The song title is "jungle" not jungle and I guess it's having trouble encoding those characters. I've read somewhere on overstock that python can use the latin-1 charmap? since it has most if not all of the characters? I've taken for understanding that it has more characters than UTF-8.

Installation Error

All works fine in installing it with pip3 install scdl (also tried with sudo) until

...
Downloading/unpacking configparser (from scdl)
  Downloading configparser-3.3.0r2.tar.gz
  Running setup.py (path:/tmp/pip_build_felix/configparser/setup.py) egg_info for package configparser
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 5, in <module>
        import distutils.core
      File "/usr/lib/python3.4/distutils/core.py", line 18, in <module>
        from distutils.config import PyPIRCCommand
      File "/usr/lib/python3.4/distutils/config.py", line 7, in <module>
        from configparser import ConfigParser
      File "/tmp/pip_build_felix/configparser/configparser.py", line 397
        _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                             ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 3, in <module>

  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 5, in <module>

    import distutils.core

  File "/usr/lib/python3.4/distutils/core.py", line 18, in <module>

    from distutils.config import PyPIRCCommand

  File "/usr/lib/python3.4/distutils/config.py", line 7, in <module>

    from configparser import ConfigParser

  File "/tmp/pip_build_felix/configparser/configparser.py", line 397

    _KEYCRE = re.compile(ur"%\(([^)]+)\)s")

                                         ^

SyntaxError: invalid syntax

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_felix/configparser
Storing debug log for failure in /home/felix/.pip/pip.log

Download all favorites caps at around ~100 downloads.

For some reason running scdl -f- c will only download about 100 tracks from my favorites list.

running

favorites = client.get('/users/' + str(user.id) + '/favorites', limit=500)

yields me back about 190+ results though

404 on same song

does it every time for me on certain songs like for ex https://soundcloud.com/alisonwonderland/iwantyou-ganzflip-cdm

Traceback (most recent call last):
File "/usr/local/bin/scdl", line 9, in
load_entry_point('scdl==1.1.1', 'console_scripts', 'scdl')()
File "/usr/local/lib/python3.4/site-packages/scdl/scdl.py", line 113, in main
parse_url(arguments["-l"])
File "/usr/local/lib/python3.4/site-packages/scdl/scdl.py", line 184, in parse_url
download_user_favorites(item)
File "/usr/local/lib/python3.4/site-packages/scdl/scdl.py", line 290, in download_user_favorites
download_track(track)
File "/usr/local/lib/python3.4/site-packages/scdl/scdl.py", line 351, in download_track
stream_url = client.get(track.stream_url, allow_redirects=False)
File "/usr/local/lib/python3.4/site-packages/soundcloud/client.py", line 130, in _request
return wrapped_resource(make_request(method, url, kwargs))
File "/usr/local/lib/python3.4/site-packages/soundcloud/request.py", line 135, in make_request
result.raise_for_status()
File "/usr/local/lib/python3.4/site-packages/requests/models.py", line 831, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found

Force download of streamed track

Sometimes I may want to download the streamed version of the track rather than the original file, even if original file is available.

Maybe the original file is a WAV and I want to have an MP3 without converting, or I want to save space by downloading stream-quality music.

This is basically forcing the else part of this section of code.

Does this feature sound reasonable, or is it useless?

Progress beta state...

Working

  • Automatically detect which kind of Soundcloud's link you have provided
  • Download all song of an user
  • Download all song & repost of an user
  • Download all song of one playlist
  • Download all song of all playlist of an user
  • Download all song of an user's favorites
  • Set the tags with mutagen (title / Arstist name / album = 'Soundcloud' / Artwork)
  • Custom Offset
  • Add the artist name to the filename if it isn't in the filename already

Todo

  • rtmp support

Solved from the bash version

config is erased

Config is erased with each update of scdl. it would be great if we could fix this ...

Using scdl in Docker: UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in position 15: ordinal not in range(128)

i am using docker ( https://github.com/dghubble-docker/python3.git ) to run scdl.
i added the following to the Dockerfile:

RUN pip3 install scdl
ADD config/scdl.cfg /root/.config/scdl/scdl.cfg

to run the container and inside it scdl i start the container the following way:

docker run -t -i dghubble/python3

now scdl -l [someurl] works perfectly. really awesome, loving it!!!
but

scdl me -f

printed an error because my name contains a "ö".
after changing my name this error was gone.

however it seems as if there is a problem with one of the songs in my favorites.
i still get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/scdl", line 9, in <module>
    load_entry_point('scdl==1.3.2', 'console_scripts', 'scdl')()
  File "/usr/local/lib/python3.4/dist-packages/scdl/scdl.py", line 120, in main
    download_user_favorites(who_am_i())
  File "/usr/local/lib/python3.4/dist-packages/scdl/scdl.py", line 291, in download_user_favorites
    log('Favorite n\xb0%d' % (count), strverbosity=1)
  File "/usr/local/lib/python3.4/dist-packages/scdl/scdl.py", line 67, in log
    print(colored(str, 'white'))
UnicodeEncodeError: 'ascii' codec can't encode character '\xb0' in position 15: ordinal not in range(128)

is that because of my docker environment? it shouldn't be, should it? because its based on ubuntu and my host system is arch.

using --error fixes the problem, but some files seem to be missing (its a looong playlist, hard to compare).

i really appreciate the effort put into this script! nice work!

Name output file manually

Something like scdl -l <track_url> -O myFilename.mp3 would be convenient. We can't use -of I guess, because -o and -f are already in use and it would be confusing.

Currently I use scdl in a script, and it would be much easier to do stuff with the downloaded file if I knew what the output filename was going to be.

download failure for artists that have escape charter in display name

i thought this script did not work, but its just this one artist. otherwise, thank you for this, it's truly amazing. here's what's happening:

$ scdl -l https://soundcloud.com/mr_carmack
---------------------------------------------------------------------------
| SoundcloudMusicDownloader | FlyinGrub rework |
---------------------------------------------------------------------------
[i] Using URL : https://soundcloud.com/mr_carmack
[i] Path where i will download music : /home/ryan/music/soundcloud/
[i] I will exit if i found a file that already exist
[i] Detected download type : All of one user's songs
[i] Grabbing artists page

[i] Song n°1
[i] Grabbing artists page
[-] Downloading ALL DAY x jerrea...

################################################################## 100.0%Warning: Failed to create the file MR•CAR/\ACK - ALL DAY x jerrea.mp3: No

Warning: such file or directory

his display name is MR•CAR/\ACK and i think the double backslash is the root cause. is there a way around this? thanks!

edit: even github is parsing out the double back slash in display name :P

Avoid evil global variables

Instead, you can:

  • Functional programming: Add them as arguments to the functions (even with default values)
  • Convert functions to methods of a class, because those global variables are a shared state

scdl.cfg

As we must run pip as root, the script install scdl.cfg in the user's directory so /root .
Just to copy paste by hand the conf and place it in $HOME/.config/scdl/scdl.cfg

Keep track of how many already downloaded?

Hey there - loving your app. Amazing.

It would be excellent if on the local side, there was a json file or something that knew what had been already downloaded so that when I tru something like scdl -l www.soudncloud.com/userx -a it will know if anything new has been added since last time without needing to go through the whole list.

I hope that makes sense?

Installation failure due to regexp compilation

This happened when i ran pip3 install scdl on Ubuntu 14.10:

Downloading/unpacking configparser (from scdl)
  Downloading configparser-3.3.0r2.tar.gz
  Running setup.py (path:/tmp/pip_build_cos/configparser/setup.py) egg_info for package configparser
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 5, in <module>
        import distutils.core
      File "/usr/lib/python3.4/distutils/core.py", line 18, in <module>
        from distutils.config import PyPIRCCommand
      File "/usr/lib/python3.4/distutils/config.py", line 7, in <module>
        from configparser import ConfigParser
      File "/tmp/pip_build_cos/configparser/configparser.py", line 397
        _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                             ^
    SyntaxError: invalid syntax

Can songs be tagged with album art?

Really like this tool, tried to write my own before I discovered this one. Only thing about mine, is that it downloaded the album arm and automatically tagged the song with it. Would this be hard/possible to implement in scdl? I'm willing to take a hack at it, but I'm no python expert.

configparser dependency breaks setup.py

When installing scdl with pip3, it breaks over configparser:

Downloading/unpacking scdl
Downloading scdl-v1.0.3.tar.gz
Running setup.py (path:/tmp/pip_build_root/scdl/setup.py) egg_info for package scdl

Requirement already satisfied (use --upgrade to upgrade): docopt in /usr/lib64/python3.4/site-packages (from scdl)
Requirement already satisfied (use --upgrade to upgrade): soundcloud in /usr/lib64/python3.4/site-packages (from scdl)
Requirement already satisfied (use --upgrade to upgrade): wget in /usr/lib64/python3.4/site-packages (from scdl)
Downloading/unpacking configparser (from scdl)
Downloading configparser-3.3.0r2.tar.gz
Running setup.py (path:/tmp/pip_build_root/configparser/setup.py) egg_info for package configparser
Traceback (most recent call last):
File "", line 3, in
File "/usr/lib64/python3.4/site-packages/setuptools/init.py", line 5, in
import distutils.core
File "/usr/lib64/python3.4/distutils/core.py", line 18, in
from distutils.config import PyPIRCCommand
File "/usr/lib64/python3.4/distutils/config.py", line 7, in
from configparser import ConfigParser
File "/tmp/pip_build_root/configparser/configparser.py", line 397
_KEYCRE = re.compile(ur"%(([^)]+))s")
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 3, in

File "/usr/lib64/python3.4/site-packages/setuptools/init.py", line 5, in

import distutils.core

File "/usr/lib64/python3.4/distutils/core.py", line 18, in

from distutils.config import PyPIRCCommand

File "/usr/lib64/python3.4/distutils/config.py", line 7, in

from configparser import ConfigParser

File "/tmp/pip_build_root/configparser/configparser.py", line 397

_KEYCRE = re.compile(ur"%(([^)]+))s")

                                     ^

SyntaxError: invalid syntax

Cleaning up...

Some google on this issue told me configparser seems to be build in python3+. There should be no need to have this package as a dependency.

The package downloaded by pip is a backport to 2.7

https://pypi.python.org/pypi/configparser

If you'd like to use the backport on Python 2 and the built-in version on Python 3

When downloading from github it runs without having configparser.

Random error resolving url

this error happened twice while downloading all my repost (~700), the script actually stops when it encounter it. When i retried downloading where it stopped it worked well.

syntax error

after starting pip install i get syntax error

Downloading/unpacking configparser (from scdl)
  Downloading configparser-3.3.0r2.tar.gz
  Running setup.py (path:/tmp/pip_build_root/configparser/setup.py) egg_info for package configparser
    Traceback (most recent call last):
      File "<string>", line 3, in <module>
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 5, in <module>
        import distutils.core
      File "/usr/lib/python3.4/distutils/core.py", line 18, in <module>
        from distutils.config import PyPIRCCommand
      File "/usr/lib/python3.4/distutils/config.py", line 7, in <module>
        from configparser import ConfigParser
      File "/tmp/pip_build_root/configparser/configparser.py", line 397
        _KEYCRE = re.compile(ur"%\(([^)]+)\)s")
                                             ^
    SyntaxError: invalid syntax
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 3, in <module>

  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 5, in <module>

    import distutils.core

  File "/usr/lib/python3.4/distutils/core.py", line 18, in <module>

    from distutils.config import PyPIRCCommand

  File "/usr/lib/python3.4/distutils/config.py", line 7, in <module>

    from configparser import ConfigParser

  File "/tmp/pip_build_root/configparser/configparser.py", line 397

    _KEYCRE = re.compile(ur"%\(([^)]+)\)s")

                                         ^

SyntaxError: invalid syntax

Bug: Download stops after 100 tracks

It's because of this strange code:

tracks = client.get('/users/' + str(user.id) + '/tracks', limit=10, offset=offset)
for track in tracks:
    for track in tracks:
        ....

limit = 10, so 10 x 10 = 100, is that a conspiracy?

I already have a working solution, but I wanna warn you first.

scdl: command not found

We had an issue getting this installed when a non-Homebrew version of Python 3 had already been installed. The solution, without using vim/emacs/nano/etc:

# install homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

# test homebrew
brew doctor

# install python3
brew install python3

# install scdl
sudo pip3 install --upgrade --force-reinstall scdl

# edit config
open /Applications/TextEdit.app/ $HOME/.config/scdl/scdl.cfg

# test
scdl -h

Just wanted to make an issue to document in case anyone else is Googling around. Thanks!

Playlist features

  • Create a subfolder with the name of the playlist and download the song in it
  • Add the playlist name to the album tag

High CPU usage in tmux

If I run scdl in tmux the tmux process takes up 15-20% CPU (on a 1.9GHz dual-core CPU). High CPU usage happens whether I run tmux from a tty or a terminal emulator (Konsole). High CPU usage doesn't happen if I run scdl outside of tmux in Konsole.

In my experience this is probably caused by the progress bar being redrawn waaay too often. If I run scdl -l some_url &> /tmp/stdout.txt (thus hiding the progress bar) the high CPU usage problem doesn't occur.

Would you consider reducing the progress bar's incredibly high refresh rate? The human eye can't even keep up when the numbers change so quickly.

PS: Many thanks for this very useful program :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.