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()
|
||||||
try:
|
feed_fetched = False
|
||||||
database.read_feed()
|
if args.refresh:
|
||||||
except urllib.error.URLError as err:
|
try:
|
||||||
if args.action == "download" or not cache:
|
database.read_feed()
|
||||||
raise err
|
feed_fetched = True
|
||||||
else:
|
except urllib.error.URLError as err:
|
||||||
log.warning("Cannot fetch RSS feed, using cached feed.", err)
|
if args.action == "download":
|
||||||
|
raise RuntimeError("Couldn't fetch feed, refusing to download")
|
||||||
|
# This is a quirky failsafe in case of no internet connection,
|
||||||
|
# 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