suyashb95 / soundcloud-dl

A Python project that downloads tracks from soundcloud.com, complete with metadata and album art
125 stars 19 forks source link

AttributeError: 'NoneType' object has no attribute 'close' #12

Closed xenithorb closed 7 years ago

xenithorb commented 7 years ago

Python 2

$ soundcloud-dl https://soundcloud.com/greg-dugast/tracks
Connecting ...
Saving in: /home/xenith/Nextcloud/Music/SoundCloud/Degree

Connecting to stream...
Response: 200
Degree - Sheltered Love.mp3 already exists, skipping.

Connecting to stream...
Response: 200
Degree - Midnight Thunder.mp3 already exists, skipping.

Connecting to stream...
Response: 200
Degree - Silence.mp3 already exists, skipping.

Connecting to stream...
Connection error or invalid URL.
Traceback (most recent call last):
  File "/home/xenith/virtualenvs/soundcloud_dl/bin/soundcloud-dl", line 11, in <module>
    sys.exit(main())
  File "/home/xenith/virtualenvs/soundcloud_dl/lib/python2.7/site-packages/soundcloud_dl/soundcloud_dl.py", line 36, in main
    downloaderObject.Download()
  File "/home/xenith/virtualenvs/soundcloud_dl/lib/python2.7/site-packages/soundcloud_dl/downloader/downloader.py", line 412, in Download
    self.getSingleTrack(track)
  File "/home/xenith/virtualenvs/soundcloud_dl/lib/python2.7/site-packages/soundcloud_dl/downloader/downloader.py", line 95, in getSingleTrack
    new_filename = self.getFile(filename, url)
  File "/home/xenith/virtualenvs/soundcloud_dl/lib/python2.7/site-packages/soundcloud_dl/downloader/downloader.py", line 229, in getFile
    raise KeyboardInterrupt
  File "/usr/lib64/python2.7/contextlib.py", line 154, in __exit__
    self.thing.close()
AttributeError: 'NoneType' object has no attribute 'close'
Python 3
$ soundcloud-dl https://soundcloud.com/greg-dugast/tracks
Connecting ... 
Saving in: /home/xenith/Nextcloud/Music/SoundCloud/Degree

Connecting to stream...
Response: 200
Degree - Sheltered Love.mp3 already exists, skipping.

Connecting to stream...
Response: 200
Degree - Midnight Thunder.mp3 already exists, skipping.

Connecting to stream...
Response: 200
Degree - Silence.mp3 already exists, skipping.

Connecting to stream...
Connection error or invalid URL.
Traceback (most recent call last):
  File "/home/xenith/virtualenvs/soundcloud_dl3/lib64/python3.5/site-packages/soundcloud_dl/downloader/downloader.py", line 193, in getFile
    print("Response: "+ str(response.status_code))
AttributeError: 'NoneType' object has no attribute 'status_code'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/xenith/virtualenvs/soundcloud_dl3/bin/soundcloud-dl", line 11, in <module>
    sys.exit(main())
  File "/home/xenith/virtualenvs/soundcloud_dl3/lib64/python3.5/site-packages/soundcloud_dl/soundcloud_dl.py", line 36, in main
    downloaderObject.Download()
  File "/home/xenith/virtualenvs/soundcloud_dl3/lib64/python3.5/site-packages/soundcloud_dl/downloader/downloader.py", line 412, in Download
    self.getSingleTrack(track)
  File "/home/xenith/virtualenvs/soundcloud_dl3/lib64/python3.5/site-packages/soundcloud_dl/downloader/downloader.py", line 95, in getSingleTrack
    new_filename = self.getFile(filename, url)
  File "/home/xenith/virtualenvs/soundcloud_dl3/lib64/python3.5/site-packages/soundcloud_dl/downloader/downloader.py", line 229, in getFile
    raise KeyboardInterrupt
  File "/usr/lib64/python3.5/contextlib.py", line 162, in __exit__
    self.thing.close()
AttributeError: 'NoneType' object has no attribute 'close'

Versions:

$ pip show soundcloud_dl
Name: soundcloud-dl
Version: 0.1.14
Summary: A tool to download tracks from soundcloud.com
Home-page: https://github.com/Suyash458/soundcloud-dl
Author: Suyash Behera
Author-email: sne9x@outlook.com
License: UNKNOWN
Location: /home/xenith/virtualenvs/soundcloud_dl/lib/python2.7/site-packages
Requires: six, requests, mutagen, soundcloud
$ python --version
Python 2.7.13
$ python3 --version
Python 3.5.3
suyashb95 commented 7 years ago

The downloader doesn't work with python 2. I've fixed the issue with Python 3, there are rate limits in place now so you'll have to get your own API key as given here