diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 3f169056a..a20816553 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1508,6 +1508,11 @@ from .axios import ( AxiosIE ) +from .likee import ( + LikeeIE, + LikeeUserIE +) + from .zingmp3_vn import ( Zingmp3_vnIE, Zingmp3_vnPlaylistIE, diff --git a/youtube_dl/extractor/likee.py b/youtube_dl/extractor/likee.py new file mode 100644 index 000000000..17682e99d --- /dev/null +++ b/youtube_dl/extractor/likee.py @@ -0,0 +1,203 @@ +# coding: utf-8 +# Code by hatienl0i261299 - fb.com/100011734236090 - hatienloi261299@gmail.com +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..compat import ( + compat_urllib_parse_urlencode +) +from ..utils import ( + js_to_json, + int_or_none, + try_get +) + + +class LikeeIE(InfoExtractor): + _VALID_URL = r'''(?x)^((http[s]?|fpt):)\/?\/(www\.|m\.|) + (?P + (likee\.com) + )\/(?P@.+?)\/(video)\/(?P[0-9]+)$ + ''' + IE_NAME = 'likee' + IE_DESC = 'likee.com' + _TESTS = [ + { + "url": "https://likee.com/@Inayat95/video/6808497581927578387", + "info_dict": { + "id": "6808497581927578387", + "ext": "mp4", + "title": "@Inayat95_6808497581927578387", + "description": str, + "thumbnail": r"re:^https?:.+?.jpg", + "uploader": str, + "uploader_id": int, + "like_count": int, + "comment_count": int, + "share_count": int, + "view_count": int, + "download_count": int + } + }, + { + "url": "https://likee.com/@Inayat95/video/6792552721999608595", + "info_dict": { + "id": "6792552721999608595", + "ext": "mp4", + "title": "@Inayat95_6792552721999608595", + "description": str, + "thumbnail": r"re:^https?:.+?.jpg", + "uploader": str, + "uploader_id": int, + "like_count": int, + "comment_count": int, + "share_count": int, + "view_count": int, + "download_count": int + } + }, + { + "url": "https://likee.com/@435421183/video/6802046076516688592", + "info_dict": { + "id": "6802046076516688592", + "ext": "mp4", + "title": "@435421183_6802046076516688592", + "description": str, + "thumbnail": r"re:^https?:.+?.jpg", + "uploader": str, + "uploader_id": int, + "like_count": int, + "comment_count": int, + "share_count": int, + "view_count": int, + "download_count": int + } + }, + ] + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group("id") + user = mobj.group("user") + webpage = self._download_webpage( + url_or_request=url, + video_id=video_id + ) + + info_video = self._regex_data(webpage, video_id) + + if info_video.get("post_id") == video_id: + formats = [{ + "url": info_video.get("video_url") or info_video.get("video_water_url"), + "ext": "mp4", + "height": int_or_none(info_video.get("video_height")), + "width": int_or_none(info_video.get("video_width")), + "protocol": "http", + }] + + def get_count(name): + return int_or_none(info_video.get(name), default=0) + + return { + "id": video_id, + "title": "%s_%s" % (user, video_id), + "description": info_video.get("msg_text") or '', + "thumbnail": info_video.get("image1") or info_video.get("image2") or info_video.get("image3"), + "like_count": get_count("like_count"), + "view_count": get_count("play_count"), + "share_count": get_count("share_count"), + "download_count": get_count("download_count"), + "comment_count": get_count("comment_count"), + "uploader": info_video.get("nick_name"), + "uploader_id": int_or_none(info_video.get("poster_uid")), + "formats": formats + } + + def _regex_data(self, webpage, video_id): + info_video = self._parse_json(self._search_regex( + r'''