mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-06 19:45:24 +00:00
add update version
This commit is contained in:
parent
09b6e1203c
commit
2195d73616
6
Stream/upload/__version__.py
Normal file
6
Stream/upload/__version__.py
Normal 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
42
Stream/upload/update.py
Normal 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
2
run.py
@ -3,6 +3,7 @@
|
|||||||
# Class import
|
# Class import
|
||||||
import Stream.api.page as Page
|
import Stream.api.page as Page
|
||||||
from Stream.util.message import msg_start
|
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.util.console import console, msg, console_print
|
||||||
from Stream.api.film import main_dw_film as download_film
|
from Stream.api.film import main_dw_film as download_film
|
||||||
from Stream.api.tv import main_dw_tv as download_tv
|
from Stream.api.tv import main_dw_tv as download_tv
|
||||||
@ -12,6 +13,7 @@ site_version = Page.get_version(domain)
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
msg_start()
|
msg_start()
|
||||||
|
main_update()
|
||||||
|
|
||||||
film_search = msg.ask("[blue]Insert film to search: ").strip()
|
film_search = msg.ask("[blue]Insert film to search: ").strip()
|
||||||
db_title = Page.search(film_search, domain)
|
db_title = Page.search(film_search, domain)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user