aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/blerp.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2023-02-17 16:51:34 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2023-02-17 17:52:23 +0530
commit45b2ee6f4fae139892a1a4335c269dcbb6671497 (patch)
tree3cd8e7e643dc0576dcc8e9e87079f015588a06ec /yt_dlp/extractor/blerp.py
parenta5387729696a5b33f53f60ef06f48e45663b12dd (diff)
downloadhypervideo-pre-45b2ee6f4fae139892a1a4335c269dcbb6671497.tar.lz
hypervideo-pre-45b2ee6f4fae139892a1a4335c269dcbb6671497.tar.xz
hypervideo-pre-45b2ee6f4fae139892a1a4335c269dcbb6671497.zip
Update to ytdl-commit-2dd6c6e
[YouTube] Avoid crash if uploader_id extraction fails https://github.com/ytdl-org/youtube-dl/commit/2dd6c6edd8e0fc5e45865b8e6d865e35147de772 Except: * 295736c9cba714fb5de7d1c3dd31d86e50091cf8 [jsinterp] Improve parsing * 384f632e8a9b61e864a26678d85b2b39933b9bae [ITV] Overhaul ITV extractor * 33db85c571304bbd6863e3407ad8d08764c9e53b [feat]: Add support to external downloader aria2p
Diffstat (limited to 'yt_dlp/extractor/blerp.py')
-rw-r--r--yt_dlp/extractor/blerp.py167
1 files changed, 167 insertions, 0 deletions
diff --git a/yt_dlp/extractor/blerp.py b/yt_dlp/extractor/blerp.py
new file mode 100644
index 000000000..4631ad2e9
--- /dev/null
+++ b/yt_dlp/extractor/blerp.py
@@ -0,0 +1,167 @@
+import json
+
+from .common import InfoExtractor
+from ..utils import strip_or_none, traverse_obj
+
+
+class BlerpIE(InfoExtractor):
+ IE_NAME = 'blerp'
+ _VALID_URL = r'https?://(?:www\.)?blerp\.com/soundbites/(?P<id>[0-9a-zA-Z]+)'
+ _TESTS = [{
+ 'url': 'https://blerp.com/soundbites/6320fe8745636cb4dd677a5a',
+ 'info_dict': {
+ 'id': '6320fe8745636cb4dd677a5a',
+ 'title': 'Samsung Galaxy S8 Over the Horizon Ringtone 2016',
+ 'uploader': 'luminousaj',
+ 'uploader_id': '5fb81e51aa66ae000c395478',
+ 'ext': 'mp3',
+ 'tags': ['samsung', 'galaxy', 's8', 'over the horizon', '2016', 'ringtone'],
+ }
+ }, {
+ 'url': 'https://blerp.com/soundbites/5bc94ef4796001000498429f',
+ 'info_dict': {
+ 'id': '5bc94ef4796001000498429f',
+ 'title': 'Yee',
+ 'uploader': '179617322678353920',
+ 'uploader_id': '5ba99cf71386730004552c42',
+ 'ext': 'mp3',
+ 'tags': ['YEE', 'YEET', 'wo ha haah catchy tune yee', 'yee']
+ }
+ }]
+
+ _GRAPHQL_OPERATIONNAME = "webBitePageGetBite"
+ _GRAPHQL_QUERY = (
+ '''query webBitePageGetBite($_id: MongoID!) {
+ web {
+ biteById(_id: $_id) {
+ ...bitePageFrag
+ __typename
+ }
+ __typename
+ }
+ }
+
+ fragment bitePageFrag on Bite {
+ _id
+ title
+ userKeywords
+ keywords
+ color
+ visibility
+ isPremium
+ owned
+ price
+ extraReview
+ isAudioExists
+ image {
+ filename
+ original {
+ url
+ __typename
+ }
+ __typename
+ }
+ userReactions {
+ _id
+ reactions
+ createdAt
+ __typename
+ }
+ topReactions
+ totalSaveCount
+ saved
+ blerpLibraryType
+ license
+ licenseMetaData
+ playCount
+ totalShareCount
+ totalFavoriteCount
+ totalAddedToBoardCount
+ userCategory
+ userAudioQuality
+ audioCreationState
+ transcription
+ userTranscription
+ description
+ createdAt
+ updatedAt
+ author
+ listingType
+ ownerObject {
+ _id
+ username
+ profileImage {
+ filename
+ original {
+ url
+ __typename
+ }
+ __typename
+ }
+ __typename
+ }
+ transcription
+ favorited
+ visibility
+ isCurated
+ sourceUrl
+ audienceRating
+ strictAudienceRating
+ ownerId
+ reportObject {
+ reportedContentStatus
+ __typename
+ }
+ giphy {
+ mp4
+ gif
+ __typename
+ }
+ audio {
+ filename
+ original {
+ url
+ __typename
+ }
+ mp3 {
+ url
+ __typename
+ }
+ __typename
+ }
+ __typename
+ }
+
+ ''')
+
+ def _real_extract(self, url):
+ audio_id = self._match_id(url)
+
+ data = {
+ 'operationName': self._GRAPHQL_OPERATIONNAME,
+ 'query': self._GRAPHQL_QUERY,
+ 'variables': {
+ '_id': audio_id
+ }
+ }
+
+ headers = {
+ 'Content-Type': 'application/json'
+ }
+
+ json_result = self._download_json('https://api.blerp.com/graphql',
+ audio_id, data=json.dumps(data).encode('utf-8'), headers=headers)
+
+ bite_json = json_result['data']['web']['biteById']
+
+ info_dict = {
+ 'id': bite_json['_id'],
+ 'url': bite_json['audio']['mp3']['url'],
+ 'title': bite_json['title'],
+ 'uploader': traverse_obj(bite_json, ('ownerObject', 'username'), expected_type=strip_or_none),
+ 'uploader_id': traverse_obj(bite_json, ('ownerObject', '_id'), expected_type=strip_or_none),
+ 'ext': 'mp3',
+ 'tags': list(filter(None, map(strip_or_none, (traverse_obj(bite_json, 'userKeywords', expected_type=list) or []))) or None)
+ }
+
+ return info_dict