]> jfr.im git - yt-dlp.git/commitdiff
[mixcloud] Detect restrictions (#2169)
authorLE <redacted>
Fri, 31 Dec 2021 20:11:35 +0000 (15:11 -0500)
committerGitHub <redacted>
Fri, 31 Dec 2021 20:11:35 +0000 (01:41 +0530)
Authored by; llacb47

yt_dlp/extractor/mixcloud.py

index a0c043d4bd324f2f9bd8f831dca08080481199aa..c2dd078ac42f0bfd533957170ce7f77d003bdf51 100644 (file)
@@ -12,6 +12,7 @@
     compat_zip
 )
 from ..utils import (
+    ExtractorError,
     int_or_none,
     parse_iso8601,
     strip_or_none,
@@ -125,7 +126,20 @@ def _real_extract(self, url):
       tag {
         name
       }
-    }''', track_id, username, slug)
+    }
+    restrictedReason
+    id''', track_id, username, slug)
+
+        if not cloudcast:
+            raise ExtractorError('Track not found', expected=True)
+
+        reason = cloudcast.get('restrictedReason')
+        if reason == 'tracklist':
+            raise ExtractorError('Track unavailable in your country due to licensing restrictions', expected=True)
+        elif reason == 'repeat_play':
+            raise ExtractorError('You have reached your play limit for this track', expected=True)
+        elif reason:
+            raise ExtractorError('Track is restricted', expected=True)
 
         title = cloudcast['name']