From ee3c3aec1720e2bf1ec500153970922bd677aa3d Mon Sep 17 00:00:00 2001 From: Carlos Cardenas Date: Sat, 24 Apr 2021 17:55:24 -0400 Subject: [PATCH] [Likee] Add new extractor --- youtube_dl/extractor/extractors.py | 4 ++ youtube_dl/extractor/likee.py | 83 ++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 youtube_dl/extractor/likee.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index d5cd364e8..b45a36170 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -590,6 +590,10 @@ from .lifenews import ( LifeNewsIE, LifeEmbedIE, ) +from .likee import ( + LikeeIE, + LikeeUserIE, +) from .limelight import ( LimelightMediaIE, LimelightChannelIE, diff --git a/youtube_dl/extractor/likee.py b/youtube_dl/extractor/likee.py new file mode 100644 index 000000000..9b775fe39 --- /dev/null +++ b/youtube_dl/extractor/likee.py @@ -0,0 +1,83 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class LikeeIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?likee\.video/v/(?P\w+)' + _TEST = { + 'url': 'https://likee.video/v/k6QcOp', + 'md5': '5e0988b2ea7615075735cef87c2ca14d', + 'info_dict': { + 'id': 'k6QcOp', + 'ext': 'mp4', + 'title': 'Agua challenge 😳😱', + 'thumbnail': 'https://videosnap.like.video/na_live/3a2/1tVVI4_1.jpg?type=8', + 'uploader': 'fernanda_rivasg' + } + } + + def _real_initialize(self): + # Setup session (will set necessary cookies) + self._request_webpage( + 'https://likee.video/', None, note='Setting up session') + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + # set title + title = self._html_search_regex(r'(.+?)', webpage, 'title') + print(title + 'f') + # set thumbnail + thumbnail = self._html_search_regex(r'', webpage, 'thumbnail') + # set uploader + uploader = self._html_search_regex(r'', webpage, 'uploader') + uploader = uploader.split(',')[1] + uploader = uploader.strip() + + return { + 'id': video_id, + 'title': title, + 'thumbnail': thumbnail, + 'uploader': uploader, + 'ext': 'mp4', + 'url': url, + } + + +class LikeeUserIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?likee\.video/p/(?P\w+)' + _TEST = { + 'url': 'https://l.likee.video/p/Gp6YGd', + 'info_dict': { + 'id': 'Gp6YGd' + }, + 'playlist_mincount': 10, + } + + def _real_initialize(self): + # Setup session (will set necessary cookies) + self._request_webpage( + 'https://likee.video/', None, note='Setting up session') + + def _real_extract(self, url): + user_id = self._match_id(url) + webpage = self._download_webpage(url, user_id) + current_list = self._html_search_regex(r'\"itemListElement\": \[(.+?)\]', webpage, 'baseVideoList__list') + entries = [] + for i in range(10): + next_result = self._html_search_regex(r'\{\"@type\":\"VideoObject\",(.+?)\},?', current_list, 'baseVideoList__list') + entry = {} + entry["title"] = self._html_search_regex(r'on Likee Mobile: (.+?)\"', next_result, 'title') + temp_url = self._html_search_regex(r'\"url\":\"(.+?)\"', next_result, 'url') + entry["url"] = temp_url.replace('\\', '') + entry["thumbnail"] = self._html_search_regex(r'\"thumbnailUrl\":\"(.+?)\"', next_result, 'thumbnail') + entry["uploader"] = self._html_search_regex(r'/@(.+?)\/', next_result, 'uploader') + entry["ext"] = 'mp4' + entry["description"] = self._html_search_regex(r'\"description\":\"(.+?)\"', next_result, 'description') + entry["id"] = self._html_search_regex(r'\/video\\\/(.+?)\"', next_result, 'id') + entries.append(entry) + current_list = current_list[len(next_result):] + + return self.playlist_result(entries, user_id)