initial work to add version checker.

This commit is contained in:
ArabCoders 2024-01-21 00:12:53 +03:00
parent f4ddfb552a
commit c8b6cc39ac
2 changed files with 26 additions and 1 deletions

View file

@ -92,6 +92,7 @@ jobs:
cache-to: type=gha, scope=${{ github.workflow }} cache-to: type=gha, scope=${{ github.workflow }}
- name: Version tag - name: Version tag
if: github.event_name != 'pull_request'
uses: arabcoders/action-python-autotagger@master uses: arabcoders/action-python-autotagger@master
with: with:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}

View file

@ -8,7 +8,7 @@ import random
from Config import Config from Config import Config
from DownloadQueue import DownloadQueue from DownloadQueue import DownloadQueue
from Utils import ObjectSerializer, Notifier from Utils import ObjectSerializer, Notifier
from aiohttp import web from aiohttp import web, client
from aiohttp.web import Request, Response from aiohttp.web import Request, Response
from Webhooks import Webhooks from Webhooks import Webhooks
from player.M3u8 import M3u8 from player.M3u8 import M3u8
@ -128,6 +128,30 @@ class Main:
await self.sio.emit('initial_data', self.serializer.encode(data), to=sid) await self.sio.emit('initial_data', self.serializer.encode(data), to=sid)
async def version_check(self):
try:
with client.ClientSession() as session:
async with session.get('https://api.github.com/repos/ytptube/ytptube/tags') as r:
if r.status != 200:
return
tags = await r.json()
for tag in tags:
tagName = tag.get('name')
splitTagName = tagName.split('-')
if len(splitTagName) > 1:
tagName = splitTagName[0]
cvDate = self.config.version.split('-')
if tagName > cvDate[0]:
self.config.new_version_available = True
self.logger.info(
f'New version {tagName} available at')
break
except Exception as e:
pass
def addTasks(self): def addTasks(self):
tasks_file: str = os.path.join(self.config.config_path, 'tasks.json') tasks_file: str = os.path.join(self.config.config_path, 'tasks.json')
if not os.path.exists(tasks_file): if not os.path.exists(tasks_file):