Compare commits

..

No commits in common. "eb3c9814bb1f1f5408fa2667437cbf4050ac1493" and "2327d5388dc93f1e5d6255dcfde567ef523c0ba2" have entirely different histories.

8 changed files with 0 additions and 223 deletions

View file

@ -2,7 +2,6 @@
import os import os
import shutil import shutil
import tomllib
from pathlib import Path from pathlib import Path
from rwx import ps from rwx import ps
@ -95,19 +94,6 @@ def read_file_bytes(file_path: Path) -> bytes:
return file_object.read() return file_object.read()
def read_file_dict(file_path: Path, charset: str = CHARSET) -> dict:
"""Read whole file as toml object.
:param file_path: source input file
:type file_path: Path
:param charset: charset to use for decoding input
:type charset: str
:rtype: dict
"""
text = read_file_text(file_path, charset)
return tomllib.loads(text)
def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]: def read_file_lines(file_path: Path, charset: str = CHARSET) -> list[str]:
"""Read whole file lines. """Read whole file lines.

View file

@ -1 +0,0 @@
"""Configure FreeTube."""

View file

@ -1,29 +0,0 @@
"""FreeTube channels."""
from rwx import Class
class Channel(Class):
"""FreeTube channel."""
def __init__(self, uid: str, name: str) -> None:
"""Set uid & name.
:param uid: unique identifier
:type uid: str
:param name: label
:type name: str
"""
self.uid = uid
self.name = name
def to_db(self) -> str:
"""Return identifier as db.
:rtype: str
"""
return f"""\
{{\
"id":"{self.uid}"\
}}\
"""

View file

@ -1,21 +0,0 @@
"""Output FreeTube db."""
def to_db(value: object) -> str:
"""Render value as string.
:param value: value to render
:type value: object
:rtype: str
"""
match value:
case bool():
text = str(value).lower()
case dict():
sub = ",".join([f'"{i}":{to_db(v)}' for i, v in value.items()])
text = f"{{{sub}}}"
case float() | str():
text = f'"{value}"'
case _:
text = str(value)
return text

View file

@ -1,47 +0,0 @@
"""FreeTube playlists."""
from rwx import Class
from .videos import Video
class Playlist(Class):
"""FreeTube playlist."""
def __init__(self, uid: str, name: str) -> None:
"""Set uid & name.
:param uid: identifier
:type uid: str
:param name: label
:type name: str
"""
self.uid = uid
self.name = name
self.videos: list[Video] = []
def add(self, video: Video) -> None:
"""Add video.
:param video: video to add
:type video: Video
"""
self.videos.append(video)
def to_db(self) -> str:
"""Return identifier, name & videos.
:rtype: str
"""
videos = ",".join([video.to_db() for video in self.videos])
return f"""\
{{\
"_id":"{self.uid}"\
,\
"playlistName":"{self.name}"\
,\
"protected":true\
,\
"videos":[{videos}]\
}}\
"""

View file

@ -1,45 +0,0 @@
"""FreeTube profiles."""
from rwx import Class
from .channels import Channel
class Profile(Class):
"""FreeTube profile."""
def __init__(self, uid: str, name: str) -> None:
"""Set uid & name.
:param uid: unique identifier
:type uid: str
:param name: label
:type name: str
"""
self.id = uid
self.name = name
self.channels: list[Channel] = []
def add(self, channel: Channel) -> None:
"""Add channel.
:param channel: channel to add
:type channel: Channel
"""
self.channels.append(channel)
def to_db(self) -> str:
"""Return identifier, name & channels.
:rtype: str
"""
channels = ",".join([channel.to_db() for channel in self.channels])
return f"""\
{{\
"_id":"{self.id}"\
,\
"name":"{self.name}"\
,\
"subscriptions":[{channels}]\
}}\
"""

View file

@ -1,33 +0,0 @@
"""FreeTube settings."""
from rwx import Class
from .db import to_db
class Setting(Class):
"""FreeTube setting."""
def __init__(self, uid: str, value: object) -> None:
"""Set uid & value.
:param uid: unique identifier
:type uid: str
:param value: value
:type value: object
"""
self.uid = uid
self.value = value
def to_db(self) -> str:
"""Return uid & value as db string.
:rtype: str
"""
return f"""\
{{\
"_id":"{self.uid}"\
,\
"value":{to_db(self.value)}\
}}\
"""

View file

@ -1,33 +0,0 @@
"""FreeTube videos."""
from rwx import Class
class Video(Class):
"""FreeTube video."""
def __init__(self, uid: str, name: str) -> None:
"""Set id & name.
:param uid: identifier
:type uid: str
:param name: label
:type name: str
"""
self.uid = uid
self.name = name
def to_db(self) -> str:
"""Return identifier, zero length & title.
:rtype: str
"""
return f"""\
{{\
"videoId":"{self.uid}"\
,\
"lengthSeconds":0\
,\
"title":"{self.name}"\
}}\
"""