Extracted youtube datatypes to extractors/all module

master
Felix Stupp 1 year ago
parent 3a19ecbfcc
commit 49c5d47893
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -0,0 +1,48 @@
from __future__ import annotations
from typing import (
List,
NewType,
TypedDict,
)
Keyword = NewType("Keyword", str)
class YoutubeDuration(TypedDict):
secondsText: str
class YoutubeViewCount(TypedDict):
text: str
class YoutubeThumbnailData(TypedDict):
url: str
width: int
height: int
class YoutubeChannelData(TypedDict):
name: str
id: str
link: str
class YoutubeVideoData(TypedDict):
id: str
title: str
duration: YoutubeDuration
viewCount: YoutubeViewCount
thumbnails: List[YoutubeThumbnailData]
description: str
channel: YoutubeChannelData
allowRatings: bool
averageRating: float
keywords: List[Keyword]
isLiveContent: bool
publishDate: str
uploadDate: str
isLiveNow: bool
link: str

@ -3,7 +3,7 @@ from __future__ import annotations
from datetime import datetime from datetime import datetime
import logging import logging
import re import re
from typing import List, NewType, Optional, TypedDict from typing import Optional
from youtubesearchpython import ResultMode, Video from youtubesearchpython import ResultMode, Video
@ -12,6 +12,9 @@ from ...models import (
MediaThumbnail, MediaThumbnail,
thumbnail_sort_key, thumbnail_sort_key,
) )
from ..all.youtube import (
YoutubeVideoData,
)
from ..generic import ( from ..generic import (
AuthorExtractedData, AuthorExtractedData,
ChangedReport, ChangedReport,
@ -22,49 +25,7 @@ from ..generic import (
from .base import MediaExtractor from .base import MediaExtractor
Keyword = NewType("Keyword", str)
class YoutubeDuration(TypedDict):
secondsText: str
class YoutubeViewCount(TypedDict):
text: str
class YoutubeThumbnailData(TypedDict):
url: str
width: int
height: int
class YoutubeChannelData(TypedDict):
name: str
id: str
link: str
class YoutubeVideoData(TypedDict):
id: str
title: str
duration: YoutubeDuration
viewCount: YoutubeViewCount
thumbnails: List[YoutubeThumbnailData]
description: str
channel: YoutubeChannelData
allowRatings: bool
averageRating: float
keywords: List[Keyword]
isLiveContent: bool
publishDate: str
uploadDate: str
isLiveNow: bool
link: str
class YoutubeMediaExtractor(MediaExtractor[YoutubeVideoData]): class YoutubeMediaExtractor(MediaExtractor[YoutubeVideoData]):
__uri_regex = re.compile( __uri_regex = re.compile(
r"""^ r"""^
https?://( https?://(

Loading…
Cancel
Save