add update version

This commit is contained in:
Ghost 2023-12-26 18:29:33 +01:00
parent 09b6e1203c
commit 2195d73616
3 changed files with 50 additions and 0 deletions

View File

@ -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'

42
Stream/upload/update.py Normal file
View File

@ -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")

2
run.py
View File

@ -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)