Commit 79d85e32 authored by Javinator9889's avatar Javinator9889 🎼

First commit of the application - created methods for main and first setup

parent 81ef91d9
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData">
<serverData>
<paths name="Copy of project-level server 'Casa' (1)">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
</serverData>
</component>
</project>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8Inspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="W391" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
<option value="N803" />
</list>
</option>
</inspection_tool>
<inspection_tool class="PyUnresolvedReferencesInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredIdentifiers">
<list>
<option value="urlencode.urlencoder" />
</list>
</option>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
from argparse import ArgumentParser, Namespace
def main(arguments: Namespace):
from os import path
token = arguments.token
youtube_api_key = arguments.youtube
creator_id = arguments.creator
must_show_version = arguments.version
if must_show_version:
print("Version")
exit(0)
if not path.exists("app_data.dict"):
if not token:
ValueError("You must add token at least the first time you execute this app")
elif not youtube_api_key:
ValueError("You must include the YouTube API Key at least the first time you execute this app")
elif not creator_id:
ValueError("You must include the creator ID (Telegram) at least the first time you execute this app")
else:
with open("app_data.dict", "wb") as app_data_file:
import pickle
app_data = {"TOKEN": token,
"YT_API": youtube_api_key,
"CREATOR_ID": creator_id}
pickle.dump(app_data, app_data_file, pickle.HIGHEST_PROTOCOL)
if __name__ == '__main__':
args = ArgumentParser()
args.add_argument("-t",
"--token",
help="Telegram token obtained via BotFather",
type=str)
args.add_argument("-y",
"--youtube",
help="YouTube API Key",
type=str)
args.add_argument("-c",
"--creator",
help="Telegram ID of the creator",
type=int)
args.add_argument("-v",
"--version",
help="Application version",
action="store_true")
main(args.parse_args())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment