mirror of
https://github.com/Maks1mS/altlinux-autorepacked.git
synced 2024-12-23 22:52:59 +03:00
36 lines
896 B
Python
36 lines
896 B
Python
import re
|
|
|
|
from autorepacked import utils
|
|
from autorepacked.common_providers.base_provider import BaseProvider
|
|
|
|
|
|
class GithubReleasesProvider(BaseProvider):
|
|
_repo = ''
|
|
|
|
def _last_release_url(self):
|
|
return utils.eget([
|
|
'--get-real-url',
|
|
f'https://github.com/{self._repo}/releases/latest'
|
|
])
|
|
|
|
def _last_tag_name(self):
|
|
return self.get_version()
|
|
|
|
def _get_release_filename(self):
|
|
return ''
|
|
|
|
def get_version(self):
|
|
url = self._last_release_url()
|
|
|
|
pattern = r'\d+\.\d+\.\d+'
|
|
match = re.search(pattern, url)
|
|
if match:
|
|
return match.group()
|
|
else:
|
|
return "not found"
|
|
|
|
def get_download_url(self):
|
|
return (f"https://github.com/"
|
|
f"{self._repo}/releases/download/"
|
|
f"{self._last_tag_name()}/{self._get_release_filename()}")
|