013/Soundcloud-Downloader — pull request #9 by RossHamish (2014-03-09 01:16:48+00:00)
Title: Add feature: playlist downloading

Changelog:

- `self.title` is now `self.titleList`
- `self.streamURL` is now `self.streamURLlist`
- `def getStreamURL()` is now `def getStreamURLlist()`
- `def downloadSong()` is now `def downloadSongs()`
- `def addID3()` modified
- `def getTitleFilename()` created.

`def getStreamURLlist()`
The function now tries to get the tracks in the playlist as a list: `tracks = r.json()['tracks']`. If it fails (i.e. this is just a song, not a playlist), then it defaults to creating a tracklist containing one element: the given song.
It then iterates through tracks and append each track's `streamURL` to the `streamURLlist`.

`def downloadSongs()`
The function now iterates through `self.titleList` and `self.streamURLlist`, downloading each track in succession.

`def addID3()`
Added an index parameter `i` to allow `addID3` to know which title to add the ID3 tags for.

`def getTitleFilename()`
Cleans all characters except `"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789-_()"` from the filename. Some filenames, especially those containing `.` or `"` were causing trouble on my machine and throwing exceptions. This method fixes these exceptions. It is called in `getStreamURLlist` at line 35.