From 2b0623b116f3d7f31fbd42870dedc43e327fad12 Mon Sep 17 00:00:00 2001 From: hyeeji Date: Tue, 7 Dec 2021 03:11:01 +0900 Subject: [PATCH] Test --- youtube_dl/extractor/extractors.py | 2 ++ youtube_dl/extractor/nate.py | 50 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 youtube_dl/extractor/nate.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 6e8fc3961..bff72460e 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -721,6 +721,8 @@ from .nationalgeographic import ( NationalGeographicVideoIE, NationalGeographicTVIE, ) +from .nate import NateIE + from .naver import NaverIE from .nba import ( NBAWatchEmbedIE, diff --git a/youtube_dl/extractor/nate.py b/youtube_dl/extractor/nate.py new file mode 100644 index 000000000..b75fe2140 --- /dev/null +++ b/youtube_dl/extractor/nate.py @@ -0,0 +1,50 @@ +# coding: utf-8 +from __future__ import unicode_literals +from .common import InfoExtractor + + +class NateIE(InfoExtractor): + _VALID_URL = r'https?://(?:m\.)?tv\.nate\.com/clip/(?P[0-9]+)' + _API_BASE_TMPL = 'https://tv.nate.com/api/v1/clip/%s' + _TEST = { + 'url': 'https://tv.nate.com/clip/4300566', + #'md5': '02D3CAB3907B60C58043761F8B5BF2B3', + 'info_dict': { + 'id': '4300566', + 'ext': 'mp4', + 'title': '[심쿵엔딩] 이준호x이세영, 서로를 기억하며 끌어안는 두 사람!💕, MBC 211204 방송', + 'thumbnail': r're:^http?://.*\.jpg$', + 'upload_date': '20211204', + 'age_limit' : '15' + # TODO more properties, either as: + # * A value + # * MD5 checksum; start the string with md5: + # * A regular expression; start the string with re: + # * Any Python type (for example int or float) + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + #video_data = self._download_json( + # 'https://tv.nate.com/api/v1/clip/% s'%video_id, video_id, headers=self.geo_verification_headers()) + video_data = self._download_json(url, video_id) + + title = video_data.get('clipTitle') + thumbnail = video_data.get('contentImg') + upload_date = video_data.get('regData') + age_limit = video_data.get('targetAge') + + + # TODO more code goes here, for example ... + + return { + 'id': video_id, + 'title': title, + 'thumbnail' : thumbnail, + 'upload_date' : upload_date[:8], + 'age_limit' : age_limit + # TODO more properties (see youtube_dl/extractor/common.py) + }