Skip to content

Commit

Permalink
Added CLI & help menu
Browse files Browse the repository at this point in the history
  • Loading branch information
j54j6 committed Apr 23, 2024
1 parent af48152 commit 21e09f5
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,7 @@ Supported values:
- implementing downloader
- implementing scheme reader
- creating requirements.txt
- complete ReadME
- complete ReadME

# Postponed todos
- Implementing support for both SQLite and MySQL
36 changes: 34 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@


# Own Modules
from project_functions import check_dependencies
from project_functions import check_dependencies, show_help
from database_manager import db_init, check_db, check_table_exist, create_table
from config_handler import config, check_for_config
# Python Modules
import logging
import json
import sys
from prettytable import PrettyTable


# Init. Logging
Expand Down Expand Up @@ -116,4 +117,35 @@
result = create_table(column_data_as_json["db"]["table_name"], column_data_as_json["db"]["columns"])
if not result:
logging.error("Error while creating table! - Check log")
exit()
exit()

#All Tables exists needed to run this thing...
logging.info("All mandatory tables are existing...")

#Deciding action based on given arguments
if len(sys.argv) > 1:
#Command provided
match sys.argv[1]:
case "help":
#provide help
show_help()
case "add-subscription":
#Add a new subscription
exit()
case "del-subscription":
#Delete a subscription
exit()
case "list-subscriptions":
#Show all subscriptions
exit()
case "custom":
#Download a custom Item without being part of a subscription
exit()
case "start":
#Run the script to check for new content and download it
exit()
case "validate":
#Rehash all files and compare them to the already stored files.
exit()
else:
show_help()
29 changes: 28 additions & 1 deletion project_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,35 @@
# like controls or checks are located inside this file.
#

from prettytable import PrettyTable

def check_dependencies():
return

def check_db():
return
return

def show_help():
print("------------------------------ Help ------------------------------")
print("You asked for help... Here it is :) - Run YT-Manager with the following commands and you're good to go")
help_table = PrettyTable(['Command', 'argument', 'description'])
help_table.align['Command'] = "l"
help_table.align['argument'] = "l"
help_table.align['description'] = "l"
help_table.add_row(['--Subscriptions--', '', ''])
help_table.add_row(['add-subscription', '<<url>>', 'Add a new subscription'])
help_table.add_row(['del-subscription', '<<number>> | <<Name>>, <<delete_content>>', 'Delete a subscription. You can either provide the ID of your subscription (use list-subscriptions)'])
help_table.add_row(['', '', 'or the name of the subscription (Name of a channel). The second parameter defines if all content of this channel also should be removed (Default: False = NO)"'])
help_table.add_row(['list-subscriptions', '<<filter>>', 'List all subscriptions - You can provide a Filter (Array) of schemes you want to include'])
help_table.add_row(['', '', ''])
help_table.add_row(['--Other--', '', ''])
help_table.add_row(['validate', '', 'After any downloaded file a hash is generated and stored. For both checking for any duplicate files (independent of the name) and checking integrity of files (and maybe redownload them).'])
help_table.add_row(['', '', 'If you use this command all files will be revalidated and a report will be generated if there are any mismatches. '])
help_table.add_row(['', '', 'But be aware - This operation can take very long and consumes much power... Use it with care or overnight :) - At the end you will see a report and you can decide if mismatched files should be redonwloaded'])
help_table.add_row(['', '', ''])
help_table.add_row(['--Operation--', '', ''])
help_table.add_row(['custom', '<<url>>', 'In case you want to download a video from a channel without a subscription you can do it here... The file will saved in the default scheme based folder under /custom'])
help_table.add_row(['start', '', 'Run the script -> Check all subscriptions for new content and download it'])
print(help_table)
print("Example: yt-manager.py add-subscription youtube-url")
print("------------------------------------------------------------------")

0 comments on commit 21e09f5

Please sign in to comment.