mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-08-12 00:10:28 -04:00
skip unserializable enum YTDLPStatus
This commit is contained in:
parent
e4fa4ad6e5
commit
25f50c513e
2 changed files with 5 additions and 13 deletions
|
@ -34,7 +34,6 @@ import urllib
|
||||||
import uuid
|
import uuid
|
||||||
import yaml
|
import yaml
|
||||||
import zlib
|
import zlib
|
||||||
from enum import Enum
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,12 +191,6 @@ class ElapsedMixIn(object):
|
||||||
return dt
|
return dt
|
||||||
|
|
||||||
|
|
||||||
class YTDLPStatus(Enum):
|
|
||||||
UNKNOWN = 0
|
|
||||||
SKIP = 1
|
|
||||||
CAPTURE = 2
|
|
||||||
|
|
||||||
|
|
||||||
class Job(doublethink.Document, ElapsedMixIn):
|
class Job(doublethink.Document, ElapsedMixIn):
|
||||||
logger = logging.getLogger(__module__ + "." + __qualname__)
|
logger = logging.getLogger(__module__ + "." + __qualname__)
|
||||||
table = "jobs"
|
table = "jobs"
|
||||||
|
@ -243,7 +236,7 @@ class Site(doublethink.Document, ElapsedMixIn):
|
||||||
if not "scope" in self:
|
if not "scope" in self:
|
||||||
self.scope = {}
|
self.scope = {}
|
||||||
if not "skip_ytdlp" in self:
|
if not "skip_ytdlp" in self:
|
||||||
self.skip_ytdlp = YTDLPStatus.UNKNOWN
|
self.skip_ytdlp = None
|
||||||
|
|
||||||
# backward compatibility
|
# backward compatibility
|
||||||
if "surt" in self.scope:
|
if "surt" in self.scope:
|
||||||
|
|
|
@ -34,12 +34,11 @@ thread_local = threading.local()
|
||||||
|
|
||||||
def should_ytdlp(site, page, skip_av_seeds):
|
def should_ytdlp(site, page, skip_av_seeds):
|
||||||
# called only after we've passed needs_browsing() check
|
# called only after we've passed needs_browsing() check
|
||||||
from .model import YTDLPStatus
|
|
||||||
|
|
||||||
if page.status_code != 200:
|
if page.status_code != 200:
|
||||||
logging.info("skipping ytdlp: non-200 page status")
|
logging.info("skipping ytdlp: non-200 page status")
|
||||||
return False
|
return False
|
||||||
if site.skip_ytdlp == YTDLPStatus.SKIP:
|
if site.skip_ytdlp:
|
||||||
logging.info("skipping ytdlp: site marked skip_ytdlp")
|
logging.info("skipping ytdlp: site marked skip_ytdlp")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -56,12 +55,12 @@ def should_ytdlp(site, page, skip_av_seeds):
|
||||||
|
|
||||||
# TODO: develop UI and refactor
|
# TODO: develop UI and refactor
|
||||||
if ytdlp_seed:
|
if ytdlp_seed:
|
||||||
if site.skip_ytdlp == YTDLPStatus.UNKNOWN and ytdlp_seed in skip_av_seeds:
|
if site.skip_ytdlp is None and ytdlp_seed in skip_av_seeds:
|
||||||
logging.info("skipping ytdlp: site in skip_av_seeds")
|
logging.info("skipping ytdlp: site in skip_av_seeds")
|
||||||
site.skip_ytdlp = YTDLPStatus.SKIP
|
site.skip_ytdlp = True
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
site.skip_ytdlp = YTDLPStatus.CAPTURE
|
site.skip_ytdlp = False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue