rssVideos: Add list command
Then you know which video you should watch next :)
This commit is contained in:
parent
814b316584
commit
7d9fa984a6
|
@ -41,6 +41,9 @@ def configure_logging(args: configargparse.Namespace) -> None:
|
||||||
logger=log,
|
logger=log,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class RVCommand(enum.Enum):
|
||||||
|
download = "download"
|
||||||
|
list = "list"
|
||||||
|
|
||||||
class RVElement:
|
class RVElement:
|
||||||
title: str
|
title: str
|
||||||
|
@ -302,6 +305,15 @@ def get_args() -> configargparse.Namespace:
|
||||||
action="store_true",
|
action="store_true",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.set_defaults(subcommand=RVCommand.download)
|
||||||
|
subparsers = parser.add_subparsers(title="subcommand")
|
||||||
|
|
||||||
|
sc_download = subparsers.add_parser("download")
|
||||||
|
sc_download.set_defaults(subcommand=RVCommand.download)
|
||||||
|
|
||||||
|
sc_list = subparsers.add_parser("list")
|
||||||
|
sc_list.set_defaults(subcommand=RVCommand.list)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
args.videos = os.path.realpath(os.path.expanduser(args.videos))
|
args.videos = os.path.realpath(os.path.expanduser(args.videos))
|
||||||
|
|
||||||
|
@ -315,6 +327,7 @@ def main() -> None:
|
||||||
os.makedirs(args.videos, exist_ok=True)
|
os.makedirs(args.videos, exist_ok=True)
|
||||||
os.chdir(args.videos)
|
os.chdir(args.videos)
|
||||||
|
|
||||||
|
if args.subcommand == RVCommand.download:
|
||||||
database = RVDatabase(args)
|
database = RVDatabase(args)
|
||||||
database.read_feed()
|
database.read_feed()
|
||||||
cache = RVDatabase.load()
|
cache = RVDatabase.load()
|
||||||
|
@ -324,6 +337,13 @@ def main() -> None:
|
||||||
database.act_all()
|
database.act_all()
|
||||||
database.save()
|
database.save()
|
||||||
|
|
||||||
|
elif args.subcommand == RVCommand.list:
|
||||||
|
cache = RVDatabase.load()
|
||||||
|
if not cache:
|
||||||
|
raise FileNotFoundError("This command doesn't work without a cache yet.")
|
||||||
|
for element in cache.elements:
|
||||||
|
print(element)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue