summaryrefslogtreecommitdiff
path: root/data-collection/components/videos.py
blob: 32dc1dadf1881a896f56e8656fe20d82fd38a36a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from typing import NamedTuple, Any, Self
from datetime import datetime

class VideoTuple(NamedTuple):
    id: str
    link: str
    title: str
    published: datetime
    updated: datetime
    thumbnail: str
    summary: str

    @classmethod
    def from_rss_entry(cls, entry: Any) -> Self:
        return cls(
            id = entry.id,
            link = entry.link,
            title = entry.title,
            published = datetime.fromisoformat(entry.published),
            updated = datetime.fromisoformat(entry.updated),
            thumbnail = entry.media_thumbnail[0]["url"],
            summary = entry.summary,
        )