diff --git a/Stream/upload/__version__.py b/Stream/upload/__version__.py new file mode 100644 index 0000000..78098d3 --- /dev/null +++ b/Stream/upload/__version__.py @@ -0,0 +1,6 @@ +__title__ = 'Streaming_community' +__version__ = 'v0.4.0' +__author__ = 'Ghost6446' +__description__ = 'A command-line program to download film' +__license__ = 'MIT License' +__copyright__ = 'Copyright 2023' \ No newline at end of file diff --git a/Stream/upload/update.py b/Stream/upload/update.py new file mode 100644 index 0000000..730e132 --- /dev/null +++ b/Stream/upload/update.py @@ -0,0 +1,42 @@ +# 26.12.2023 + +# Class import +from Stream.util.console import console + +# General import +import os, requests, time + +# Variable +github_repo_name = "StreamingCommunity_api" +main = os.path.abspath(os.path.dirname(__file__)) +base = "\\".join(main.split("\\")[:-1]) + +def get_install_version(): + about = {} + with open(os.path.join(main, '__version__.py'), 'r', encoding='utf-8') as f: + exec(f.read(), about) + return about['__version__'] + +def main_update(): + + json = requests.get(f"https://api.github.com/repos/ghost6446/{github_repo_name}/releases").json()[0] + stargazers_count = requests.get(f"https://api.github.com/repos/ghost6446/{github_repo_name}").json()['stargazers_count'] + last_version = json['name'] + down_count = json['assets'][0]['download_count'] + + # Get percentaul star + if down_count > 0 and stargazers_count > 0: + percentual_stars = round(stargazers_count / down_count * 100, 2) + else: percentual_stars = 0 + + if get_install_version() != last_version: + console.log(f"[red]A new version is available") + + else: + console.log("[red]Everything up to date") + + print("\n") + console.log(f"[red]Only was downloaded [yellow]{down_count} [red]times, but only [yellow]{percentual_stars} [red]of You(!) have starred it. \n\ + [cyan]Help the repository grow today, by leaving a [yellow]star [cyan]on it and sharing it to others online!") + time.sleep(5) + print("\n") \ No newline at end of file diff --git a/run.py b/run.py index 43aecc6..dd18145 100644 --- a/run.py +++ b/run.py @@ -3,6 +3,7 @@ # Class import import Stream.api.page as Page from Stream.util.message import msg_start +from Stream.upload.update import main_update from Stream.util.console import console, msg, console_print from Stream.api.film import main_dw_film as download_film from Stream.api.tv import main_dw_tv as download_tv @@ -12,6 +13,7 @@ site_version = Page.get_version(domain) def main(): msg_start() + main_update() film_search = msg.ask("[blue]Insert film to search: ").strip() db_title = Page.search(film_search, domain)