*args, **kwargs)
self.config = config
self.jinja = JinjaEnv(loader=JinjaFSLoader(_PATH_TEMPLATES))
- self.player = Player(config.needed_tags_prefilter)
+ self.player = Player(config.needed_tags_prefilter,
+ config.whitelist_tags_prefilter)
self.downloads = DownloadsManager()
self.downloads.clean_unfinished()
self.downloads.start_thread()
def _send_files_index(self, params: _ReqMap) -> None:
filter_path = FilterStr(params.first_for('filter_path'))
needed_tags_str = params.first_for('needed_tags')
- needed_tags = (self.server.config.needed_tags_prefilter
- | Tag.from_joined(needed_tags_str))
show_absent = bool(params.first_for('show_absent'))
with DbConn() as conn:
files = VideoFile.get_filtered(
- conn, filter_path, needed_tags, show_absent)
+ conn,
+ filter_path,
+ self.server.config.needed_tags_prefilter,
+ Tag.from_joined(needed_tags_str),
+ self.server.config.whitelist_tags_prefilter,
+ show_absent)
files.sort(key=lambda t: t.rel_path)
self._send_rendered_template(_NAME_TEMPLATE_FILES,
{'files': files,
'port_remote': 8090,
'background_color': '#ffffff',
'queries_cutoff': '',
+ 'whitelist_tags_prefilter_str': '',
'needed_tags_prefilter_str': '',
'allow_file_edit': True
}
background_color: str
queries_cutoff: str
needed_tags_prefilter_str: str
+ whitelist_tags_prefilter_str: str
allow_file_edit: bool
def __init__(self):
if k.isupper() and k.startswith(ENVIRON_PREFIX)})
self.needed_tags_prefilter = Tag.from_joined(
self.needed_tags_prefilter_str)
+ self.whitelist_tags_prefilter = Tag.from_joined(
+ self.whitelist_tags_prefilter_str)
class YoutubeQuery(DbData):
def get_filtered(cls,
conn: BaseDbConn,
filter_path: FilterStr,
- needed_tags: set[Tag],
+ needed_tags_dark: set[Tag],
+ needed_tags_seen: set[Tag],
+ whitelist_tags: set[Tag],
show_absent: bool = False
) -> list[Self]:
"""Return cls.get_all matching provided filter criteria."""
return [f for f in cls.get_all(conn)
if (show_absent or f.present)
and str(filter_path).lower() in str(f.rel_path).lower()
- and not [t for t in needed_tags if t not in f.tags]]
+ and ([t for t in whitelist_tags if t in f.tags]
+ or not [t for t in needed_tags_dark if t not in f.tags])
+ and not [t for t in needed_tags_seen if t not in f.tags]]
def unused_tags(self, conn: BaseDbConn) -> set[Tag]:
"""Return tags used among other VideoFiles, not in self."""
"""MPV representation with some additional features."""
_idx: int
- def __init__(self, needed_tags_prefilter: set[Tag]) -> None:
+ def __init__(self,
+ whitelist_tags_prefilter: set[Tag],
+ needed_tags_prefilter: set[Tag],
+ ) -> None:
self.last_update = DatetimeStr('')
self._mpv: Optional[MPV] = None
self._kill_queue: Queue = Queue()
self._monitoring_kill = False
self.filter_path = FilterStr('')
+ self._whitelist_tags_prefilter = whitelist_tags_prefilter
self._needed_tags_prefilter = needed_tags_prefilter
self.needed_tags: set[Tag] = set()
self.load_files_and_start()
known_files = {
f.full_path: f for f
in VideoFile.get_filtered(
- conn, self.filter_path,
- self._needed_tags_prefilter | self.needed_tags)}
+ conn,
+ self.filter_path,
+ self._needed_tags_prefilter,
+ self.needed_tags,
+ self._whitelist_tags_prefilter)}
self.files = [known_files[p] for p in PATH_DOWNLOADS.iterdir()
if p in known_files
and p.is_file()