rssVideos: Allow skipping feed fetching
For dev speed
This commit is contained in:
parent
daff602a31
commit
00a9da6afc
|
@ -31,7 +31,7 @@ import yt_dlp
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
# TODO Lockfile, or a way to parallel watch and download
|
# TODO Lockfile, or a way to parallel watch and download
|
||||||
|
# TODO Save ytdl infos and view info separately
|
||||||
|
|
||||||
def configure_logging(args: configargparse.Namespace) -> None:
|
def configure_logging(args: configargparse.Namespace) -> None:
|
||||||
# Configure logging
|
# Configure logging
|
||||||
|
@ -491,6 +491,12 @@ def get_args() -> configargparse.Namespace:
|
||||||
help="Fetch video info again",
|
help="Fetch video info again",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
)
|
)
|
||||||
|
parser.add(
|
||||||
|
"--no-refresh",
|
||||||
|
dest="refresh",
|
||||||
|
help="Don't fetch feed",
|
||||||
|
action="store_false",
|
||||||
|
)
|
||||||
parser.add(
|
parser.add(
|
||||||
"--videos",
|
"--videos",
|
||||||
help="Directory to store videos",
|
help="Directory to store videos",
|
||||||
|
@ -574,14 +580,22 @@ def main() -> None:
|
||||||
|
|
||||||
database = RVDatabase(args)
|
database = RVDatabase(args)
|
||||||
cache = RVDatabase.load()
|
cache = RVDatabase.load()
|
||||||
|
feed_fetched = False
|
||||||
|
if args.refresh:
|
||||||
try:
|
try:
|
||||||
database.read_feed()
|
database.read_feed()
|
||||||
|
feed_fetched = True
|
||||||
except urllib.error.URLError as err:
|
except urllib.error.URLError as err:
|
||||||
if args.action == "download" or not cache:
|
if args.action == "download":
|
||||||
raise err
|
raise RuntimeError("Couldn't fetch feed, refusing to download")
|
||||||
else:
|
# This is a quirky failsafe in case of no internet connection,
|
||||||
log.warning("Cannot fetch RSS feed, using cached feed.", err)
|
# so the script doesn't go noting that no element is a video.
|
||||||
|
if not feed_fetched:
|
||||||
|
if cache:
|
||||||
|
log.warning("Using cached feed.")
|
||||||
database.import_cache(cache)
|
database.import_cache(cache)
|
||||||
|
else:
|
||||||
|
raise FileNotFoundError("Feed not fetched and no cached feed.")
|
||||||
if cache:
|
if cache:
|
||||||
database.salvage_cache(cache)
|
database.salvage_cache(cache)
|
||||||
database.clean_cache(cache)
|
database.clean_cache(cache)
|
||||||
|
|
Loading…
Reference in a new issue