#!/usr/bin/env python3
from urllib.request import urlopen, Request
import json
import os
import sys
from subprocess import run,DEVNULL,STDOUT
from autoupdater_helpers import *
os.chdir("/sources/base-pkgbuilds/yt-dlp")
url = "https://api.github.com/repos/yt-dlp/yt-dlp/releases"
headers = {
'Accept': "application/vnd.github+json",
'X-GitHub-Api-Version': "2022-11-28"
}
req = Request(url, headers=headers)
with urlopen(req, context=ssl_ctx()) as f:
versions = json.load(f)
for vdata in versions:
if vdata['draft'] is False and vdata['prerelease'] is False:
ver = vdata['tag_name']
break
print("New ver", ver)
prev_ver = pkgbuild_ver()
if ver == prev_ver:
print("Update not necessary")
sys.exit(0)
pkgbuild_new_ver(ver)
os.chdir("..")
print(f"Updating {prev_ver} to {ver}")
mpkg("yt-dlp", ver)