Skip to content

Fix stuff #1

Description

@defuse
diff --git a/track.py b/track.py
index 5710e5c..365bf71 100644
--- a/track.py
+++ b/track.py
@@ -4,6 +4,7 @@

 import urllib, re, os.path, soundcloud
 import utils
+import requests


 def download_from_url(client_id, track_url, dir, override=False):
@@ -23,7 +24,7 @@ def download_from_id(client_id, track_id, dir, override=False):
 def download(client, track, dir, override=False):
     """Download a track using the given SC client"""
     title = fix_title(track.title, track.user['username'])
-    print '"%s"' % title
+    print '"%s"' % title.encode('ascii', 'ignore')
     if not dir: dir = 'mp3'
     utils.create_dir(dir)
     file_name = utils.build_file_name(dir, title)
@@ -32,8 +33,11 @@ def download(client, track, dir, override=False):
         print "File already exists, skipped"
         return False

-    stream_url = client.get(track.stream_url, allow_redirects=False)
-    urllib.urlretrieve(stream_url.location, file_name)
+    try:
+        stream_url = client.get(track.stream_url, allow_redirects=False)
+        urllib.urlretrieve(stream_url.location, file_name)
+    except:
+        print "Error downloading file, skipped"
     return True

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions