10000 Playlist viewing by Owez · Pull Request #99 · Owez/yark · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Playlist viewing #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/Flow.drawio
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<mxfile host="app.diagrams.net" modified="2023-01-25T11:05:36.302Z" agent="5.0 (Macintosh)" etag="JIiy6rqfE_XDCuMq9ATC" version="20.8.11" type="device"><diagram name="Page-1" id="tkwtmS5oVSkWOoKScORv">7Z3fc6M2EMf/Gk+f2jEIsPN4cXJJZ5LOzWXmenm6kUEGGkCuLP/qX18JRAwRjrnDeLHDU2CRMHyXj9AuCxmgSby5Y3gePFKPRANz6G0G6GZgmqZhDsUfadlmFsMwR5nFZ6GnbDvDU/gfUUbV0V+GHlmUGnJKIx7Oy0aXJglxecmGGaPrcrMZjcq/Osc+0QxPLo5069+hx4PMOs7PQtrvSegH+S8bzlW2JcZ5Y3UmiwB7dF0wodsBmjBKebYUbyYkkurlumT9Pu/Z+npgjCS8Tgfrm4k39Hpr/7Du//18Hyx+rNDvpjraFY6W6ozV0fJtLoHP6HKumhHGyaZKeDzNmw/1AzNeT1dcKITGhLOtaJLv6AplXfJrZKh2sd4Jbo6VLSiIbedGrJzsv+57p4NYUFL8hCyGpsoDxZ68fhiN5Z9QnO1bnYRMiUfkbocDdL0OQk6e5tiVW9eCDmELeCwO48YQi2IP0YRGlKV9kYfJeOYK+4Iz+kIKWxx3TKYzsWWvB4pKv+NkXX+l91iX+5XbotxOW2qbmto3dJ1EmeLiJ7CHORa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3V0Iz/Dlunb/TK8x0LVnpaBVEpaenTsq0AIfguOPTjR8QbANm827CKLr1mNYoLkDa9wy0YG4ED460PDlxTZsKvcigB7VBXoMCrT+3Zo7khD1Ug1TOYALAQu+QtjuX51pDNa4Llh7HoqeKCNbNfc9caLRNn4x0YiGbQGAdFm+hWTdgTTjnnkV2FCB9KnWWacZ9+jblTSj1WclDoxkhz+AUXfKg0CnPEif8jzgZeKmZXFf/hzIgiH5uwnlgXyJccgDRiR4F4IafAbQ6vMFjVmrOwtCoLOgPDVVxdpK3PeP/JIwJFbwaTirj9obY3VVEysLtNTOrkrDnTi4QN2LLfTB5q9OhBZ7pjtwoYX+Wd47mWcdJjiWaZ+Beb1j4HzG5z0ydyXCQH3u58Bwdnh4rvsuIwJ9xwqZGl+P2YdSSDzn8jjwMUakDsEFH1Og/osojemq+xnm7PoGo0v/KNH5fsPyAFfwQQXqv27emCuzLlctfWlIrO7+PUa6rfBfRtDt/w==</diagram></mxfile>
66 changes: 66 additions & 0 deletions yark/archiver/playlist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Playlist archiving for channels, including links back to videos"""

from __future__ import annotations
from dataclasses import dataclass
from .archive import Archive
from enum import Enum
from .element import Element
from typing import Any


class PlaylistItemKind(Enum):
VIDEO = 1
LIVESTREAM = 2
SHORT = 3


@dataclass
class PlaylistItem:
archive: Archive
kind: PlaylistItemKind
id: str
deleted: Element

@staticmethod
def _from_archive_o(archive: Archive, entry: dict[str, Any]) -> PlaylistItem:
"""Converts archive object dict into a class-based playlist item"""
return PlaylistItem(
archive,
PlaylistItemKind(entry["kind"]),
entry["id"],
Element._from_archive_o(archive, entry["deleted"]),
)

def _to_archive_o(self) -> dict[str, Any]:
"""Converts this object to a dict to be stored in the archive"""
return {
"kind": self.kind.value,
"id": self.id,
"deleted": self.deleted._to_archive_o(),
}


@dataclass
class Playlist:
archive: Archive
id: str
videos: list[PlaylistItem]
deleted: Element

@staticmethod
def _from_archive_o(archive: Archive, entry: dict[str, Any]) -> Playlist:
"""Converts archive object dict into a class-based playlist as a whole"""
return Playlist(
archive,
entry["id"],
[PlaylistItem._from_archive_o(archive, i) for i in entry["videos"]],
Element._from_archive_o(archive, entry["deleted"]),
)

def _to_archive_o(self) -> dict[str, Any]:
"""Converts this object to a dict to be stored in the archive"""
return {
"id": self.id,
"videos": [i._to_archive_o() for i in self.videos],
"deleted": self.deleted._to_archive_o(),
}
12 changes: 6 additions & 6 deletions yark/templates/archive.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
}

.frost {
filter: blur(5px);
opacity: 0.4;
filter: blur(7.5px);
opacity: 0.75;
}

.no-videos {
Expand All @@ -75,7 +75,7 @@
}

#kind-select>a.selected {
color: #347BC6;
color: #4a6db3;
}

.not-found-code {
Expand All @@ -92,7 +92,7 @@
}

#kind-select>a.selected {
color: #5178C6;
color: #688bd0;
}
}
</style>
Expand Down Expand Up @@ -123,8 +123,8 @@ <h1 class="hero">{{ name }}</h1>
<a href="{{ url_for('routes.video', name=name, kind=kind, id=video.id) }}" class="video">
<!-- Thumbnail -->
<div class="thumbnail">
<img src="{{ url_for('routes.archive_image', name=name, file=video.thumbnail.current().id + '.webp') }}" {% if not
video.downloaded() %}class="frost" {% endif %} />
<img src="{{ url_for('routes.archive_image', name=name, file=video.thumbnail.current().id + '.webp') }}" {%
if not video.downloaded() %}class="frost" {% endif %} />
</div>
<!-- Information -->
<div class="info">
Expand Down
10 changes: 8 additions & 2 deletions yark/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@
gap: 7px;
}

.visited > a {
color: rgb(106, 191, 219);
.visited>a {
color: #4a6db3;
}

@media (prefers-color-scheme: dark) {
.visited>a {
color: #688bd0;
}
}
</style>
{% endblock %}
Expand Down
6 changes: 5 additions & 1 deletion yark/templates/video.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
}

.timestamp {
color: #5178C6;
color: #4a6db3;
margin-top: 0;
margin-bottom: 0;
}
Expand Down Expand Up @@ -210,6 +210,10 @@

@media (prefers-color-scheme: dark) {

.timestamp {
color: #688bd0;
}

.note,
#player {
background-color: rgba(255, 255, 255, 0.0225);
Expand Down
4 changes: 2 additions & 2 deletions yark/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def index():

# Show page
elif request.method == "GET":
visited = request.cookies.get("visited")
visited = request.cookies.get("recent_ar 6BE6 chives")
if visited is not None:
visited = json.loads(visited)
return render_template(
Expand Down Expand Up @@ -100,7 +100,7 @@ def video(name, kind, id):

# Return video webpage
if request.method == "GET":
title = f"{video.title.current()} · {name}"
title = f"{name} · {video.title.current()}"
views_data = json.dumps(video.views._to_archive_o())
likes_data = json.dumps(video.likes._to_archive_o())
return render_template(
Expand Down
0