Introduced Trouble(Exception) for more elegant non-fatal errors handling
[youtube-dl] / youtube_dl / utils.py
index 0f903c64a0d8c71517378143ecad1caf07cb5893..d18073d72894c905b92233d0493cf83d525a6607 100644 (file)
@@ -11,16 +11,12 @@ import sys
 import zlib
 import urllib2
 import email.utils
+import json
 
 try:
        import cStringIO as StringIO
 except ImportError:
        import StringIO
-               
-try:
-       import json
-except ImportError: # Python <2.6, use trivialjson (https://github.com/phihag/trivialjson):
-       import trivialjson as json
 
 std_headers = {
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:5.0.1) Gecko/20100101 Firefox/5.0.1',
@@ -294,6 +290,13 @@ class ContentTooShortError(Exception):
                self.expected = expected
 
 
+class Trouble(Exception):
+       """Trouble helper exception
+       
+       This is an exception to be handled with
+       FileDownloader.trouble
+       """
+
 class YoutubeDLHandler(urllib2.HTTPHandler):
        """Handler for HTTP requests and responses.