[go] Improve geo restriction detection and use geo bypass mechanism
authorSergey M․ <dstftw@gmail.com>
Sat, 4 Feb 2017 11:51:33 +0000 (18:51 +0700)
committerSergey M <dstftw@gmail.com>
Sat, 18 Feb 2017 21:10:08 +0000 (05:10 +0800)
youtube_dl/extractor/go.py

index f28e6fbf57aa3d9355b4179908d94f5b764ec2b2..ec902c670174eb7aedca3417b0cedc8621baea42 100644 (file)
@@ -101,6 +101,10 @@ class GoIE(AdobePassIE):
                         video_id, data=urlencode_postdata(data), headers=self.geo_verification_headers())
                     errors = entitlement.get('errors', {}).get('errors', [])
                     if errors:
+                        for error in errors:
+                            if error.get('code') == 1002:
+                                self.raise_geo_restricted(
+                                    error['message'], countries=['US'])
                         error_message = ', '.join([error['message'] for error in errors])
                         raise ExtractorError('%s said: %s' % (self.IE_NAME, error_message), expected=True)
                     asset_url += '?' + entitlement['uplynkData']['sessionKey']