mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 23:49:38 +00:00
handle is_watched state in backend
This commit is contained in:
@@ -275,3 +275,19 @@ def get_channel_overwrites() -> dict[str, dict[str, Any]]:
|
||||
overwrites = {i["channel_id"]: i["channel_overwrites"] for i in result}
|
||||
|
||||
return overwrites
|
||||
|
||||
|
||||
def calc_is_watched(duration: float, position: float) -> bool:
|
||||
"""considered watched based on duration position"""
|
||||
|
||||
if not duration or duration <= 0:
|
||||
return False
|
||||
|
||||
if duration < 60:
|
||||
threshold = 0.5
|
||||
elif duration > 900:
|
||||
threshold = 1 - (180 / duration)
|
||||
else:
|
||||
threshold = 0.9
|
||||
|
||||
return position >= duration * threshold
|
||||
|
||||
@@ -45,7 +45,11 @@ class SearchProcess:
|
||||
if not all_positions:
|
||||
return None
|
||||
|
||||
pos_index = {i["youtube_id"]: i["position"] for i in all_positions}
|
||||
pos_index = {
|
||||
i["youtube_id"]: i["position"]
|
||||
for i in all_positions
|
||||
if not i.get("watched")
|
||||
}
|
||||
return pos_index
|
||||
|
||||
def _process_result(self, result):
|
||||
|
||||
Reference in New Issue
Block a user