From ca3abff9eaa30aaf8c5be21396c508139402fee0 Mon Sep 17 00:00:00 2001 From: selfisekai Date: Sat, 7 Nov 2020 04:13:19 +0100 Subject: [PATCH] aliexpress product video extractor --- haruhi_dl/extractor/aliexpress.py | 44 +++++++++++++++++++++++++++++++ haruhi_dl/extractor/extractors.py | 5 +++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/haruhi_dl/extractor/aliexpress.py b/haruhi_dl/extractor/aliexpress.py index 6f241e683..6b9afa80a 100644 --- a/haruhi_dl/extractor/aliexpress.py +++ b/haruhi_dl/extractor/aliexpress.py @@ -10,6 +10,7 @@ from ..utils import ( class AliExpressLiveIE(InfoExtractor): + IE_NAME = 'aliexpress:live' _VALID_URL = r'https?://live\.aliexpress\.com/live/(?P\d+)' _TEST = { 'url': 'https://live.aliexpress.com/live/2800002704436634', @@ -51,3 +52,46 @@ class AliExpressLiveIE(InfoExtractor): 'timestamp': float_or_none(data.get('startTimeLong'), scale=1000), 'formats': formats, } + + +class AliExpressProductIE(InfoExtractor): + IE_NAME = 'aliexpress:product' + + _TESTS = [{ + 'url': 'https://pl.aliexpress.com/item/4000570726711.html', + 'info_dict': { + 'id': '249591332087', + 'title': str, # depends on IP location + 'ext': 'mp4', + }, + }, { + 'url': 'https://www.aliexpress.com/item/4000813110155.html', + 'info_dict': { + 'id': '274294663774', + 'title': str, # depends on IP location + 'ext': 'mp4', + }, + }] + + _VALID_URL = r'https?://(?:(?:www|[a-z]{2})\.)?aliexpress\.(?:com|ru)/item/(?P\d+)\.html' + + def _real_extract(self, url): + pid = self._match_id(url) + webpage = self._download_webpage(url, pid, 'Downloading product page') + + vid = self._search_regex( + r'"videoId"\s*:\s*"?(\d+)"?', + webpage, 'video id') + uid = self._search_regex( + r'"videoUid"\s*:\s*"?(?P\d+)"?', + webpage, 'video uid') + + og_title = self._og_search_title(webpage) + title = self._search_regex(r'^.*?\|(.+?)\|', og_title, 'product title', default=og_title) + + return { + # I have no idea what these params mean but it at least seems to work + 'url': 'https://cloud.video.taobao.com/play/u/%s/p/1/e/6/t/10301/%s.mp4' % (uid, vid), + 'id': vid, + 'title': title, + } diff --git a/haruhi_dl/extractor/extractors.py b/haruhi_dl/extractor/extractors.py index 624a430e8..217bff4d0 100644 --- a/haruhi_dl/extractor/extractors.py +++ b/haruhi_dl/extractor/extractors.py @@ -42,7 +42,10 @@ from .animeondemand import AnimeOnDemandIE from .anvato import AnvatoIE from .aol import AolIE from .allocine import AllocineIE -from .aliexpress import AliExpressLiveIE +from .aliexpress import ( + AliExpressLiveIE, + AliExpressProductIE, +) from .apa import APAIE from .aparat import AparatIE from .appleconnect import AppleConnectIE