Changed project structure. Moved a lot of code into python scripts and seperated remaining shell and python scripts into their own folder. Added requirements.txt file for needed python dependencies. Updated flatpak configuration to respect new build structure.
This commit is contained in:
1 parent
3d6afd26a4
commit
2aac2d136c
14 files changed
+268
-249
No files matched your search
@@ -0,0 +1,99 @@
|
||||
import datetime
|
||||
import json
|
||||
import re
|
||||
|
||||
import requests
|
||||
|
||||
from resolve_download import Version
|
||||
|
||||
|
||||
def build_metainfo(app_id: str, app_description: str, app_tag: str):
|
||||
response = requests.get('https://www.blackmagicdesign.com/api/support/en/downloads.json')
|
||||
|
||||
parsed_response = json.loads(response.content)
|
||||
|
||||
latest_description = ""
|
||||
|
||||
releases = ""
|
||||
for idx, download in enumerate(parsed_response["downloads"]):
|
||||
if "Linux" not in download["urls"] or download["urls"]["Linux"][0]["product"] != app_tag:
|
||||
continue
|
||||
|
||||
linux = download["urls"]["Linux"][0]
|
||||
description = download["desc"]
|
||||
beta = re.compile(r'.*Beta (\d+)').match(linux["downloadTitle"])
|
||||
version = Version(
|
||||
major=linux["major"],
|
||||
minor=linux["minor"],
|
||||
patch=linux["releaseNum"],
|
||||
build=linux["releaseId"],
|
||||
beta=-1 if beta is None or beta.group(1) == "" else beta.group(1)
|
||||
)
|
||||
date = datetime.datetime.strptime(download["date"], '%d %b %Y').strftime("%Y-%m%d")
|
||||
|
||||
if idx == 0 or latest_description == "":
|
||||
latest_description = description
|
||||
|
||||
release = """<release version=\"""" + str(version) + """\" date=\"""" + date + """\">
|
||||
<description>
|
||||
""" + description + """
|
||||
</description>
|
||||
</release>"""
|
||||
|
||||
releases += release
|
||||
|
||||
template = """
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright 2013 First Lastname <your@email.com> -->
|
||||
<component type="desktop-application">
|
||||
<id>""" + app_id + """</id>
|
||||
<metadata_license>FSFAP</metadata_license>
|
||||
<project_license>LicenseRef-proprietary</project_license>
|
||||
<name>""" + app_description + """</name>
|
||||
<summary>Professional Editing, Color, Effects and Audio Post!</summary>
|
||||
|
||||
<description>
|
||||
<p>
|
||||
""" + latest_description + """
|
||||
</p>
|
||||
</description>
|
||||
|
||||
<launchable type="desktop-id">""" + app_id + """.desktop</launchable>
|
||||
|
||||
<screenshots>
|
||||
<screenshot type="default">
|
||||
<caption>DaVinci Resolve 18 Cut Page</caption>
|
||||
<image>https://images.blackmagicdesign.com/images/products/davinciresolve/overview/onesolution/carousel/cut.jpg</image>
|
||||
</screenshot>
|
||||
<screenshot>
|
||||
<caption>DaVinci Resolve 18 Edit Page</caption>
|
||||
<image>https://images.blackmagicdesign.com/images/products/davinciresolve/overview/onesolution/carousel/edit.jpg</image>
|
||||
</screenshot>
|
||||
<screenshot>
|
||||
<caption>DaVinci Resolve 18 Color Page</caption>
|
||||
<image>https://images.blackmagicdesign.com/images/products/davinciresolve/overview/onesolution/carousel/color.jpg</image>
|
||||
</screenshot>
|
||||
<screenshot>
|
||||
<caption>DaVinci Resolve 18 Fusion Page</caption>
|
||||
<image>https://images.blackmagicdesign.com/images/products/davinciresolve/overview/onesolution/carousel/fusion.jpg</image>
|
||||
</screenshot>
|
||||
<screenshot>
|
||||
<caption>DaVinci Resolve 18 Fairlight Page</caption>
|
||||
<image>https://images.blackmagicdesign.com/images/products/davinciresolve/overview/onesolution/carousel/fairlight.jpg</image>
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
|
||||
<url type="homepage">https://www.blackmagicdesign.com/products/davinciresolve</url>
|
||||
<project_group>Blackmagicdesign</project_group>
|
||||
|
||||
<provides>
|
||||
<binary>resolve</binary>
|
||||
</provides>
|
||||
|
||||
<releases>
|
||||
""" + releases + """
|
||||
</releases>
|
||||
</component>
|
||||
"""
|
||||
with open(f"/app/share/metainfo/{app_id}.metainfo.xml", 'w') as f:
|
||||
f.write(template)
|
||||
@@ -0,0 +1,22 @@
|
||||
import sys
|
||||
|
||||
from build_metainfo import *
|
||||
from resolve_download import *
|
||||
|
||||
if __name__ == "__main__":
|
||||
is_studio = '--studio' in sys.argv
|
||||
app_tag = "davinci-resolve-studio" if is_studio else "davinci-resolve"
|
||||
|
||||
print("Requesting version information...")
|
||||
(version, release_id, download_id) = get_latest_version_information(
|
||||
refer_id='77ef91f67a9e411bbbe299e595b4cfcc',
|
||||
app_tag=app_tag,
|
||||
)
|
||||
print(f"Download latest version of Davinchi Resolve{' Studio' if is_studio else ''}...")
|
||||
download_using_id(download_id)
|
||||
print(f"Building meta info...")
|
||||
build_metainfo(
|
||||
app_id='com.blackmagic.ResolveStudio' if is_studio else 'com.blackmagic.Resolve',
|
||||
app_description="DaVinci Resolve Studio" if is_studio else 'DaVinchi Resolve',
|
||||
app_tag=app_tag,
|
||||
)
|
||||
@@ -0,0 +1,88 @@
|
||||
import json
|
||||
import zipfile
|
||||
|
||||
import requests
|
||||
|
||||
from version import Version
|
||||
|
||||
cookies = {
|
||||
'_ga': 'GA1.2.1849503966.1518103294',
|
||||
'_gid': 'GA1.2.953840595.1518103294',
|
||||
}
|
||||
|
||||
headers = {
|
||||
'Host': 'www.blackmagicdesign.com',
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Origin': 'https://www.blackmagicdesign.com',
|
||||
'User-Agent': "Mozilla/5.0 (X11; Linux) \
|
||||
AppleWebKit/537.36 (KHTML, like Gecko) \
|
||||
Chrome/77.0.3865.75 \
|
||||
Safari/537.36",
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
'Authority': 'www.blackmagicdesign.com',
|
||||
'Cookie': '_ga=GA1.2.1849503966.1518103294; _gid=GA1.2.953840595.1518103294',
|
||||
}
|
||||
|
||||
|
||||
def get_latest_version_information(app_tag: str, refer_id: str = '77ef91f67a9e411bbbe299e595b4cfcc'):
|
||||
data = {
|
||||
"product": app_tag,
|
||||
"platform": "linux"
|
||||
}
|
||||
|
||||
response: requests.Response = requests.post(
|
||||
"https://www.blackmagicdesign.com/api/support/latest-version",
|
||||
cookies=cookies,
|
||||
headers={
|
||||
**headers,
|
||||
'Referer': 'https://www.blackmagicdesign.com/support/download/' + refer_id + '/Linux',
|
||||
},
|
||||
data=json.dumps(data),
|
||||
)
|
||||
|
||||
parsed_response = json.loads(response.content.decode('utf-8'))
|
||||
|
||||
return (Version(
|
||||
major=parsed_response["linux"]["major"],
|
||||
minor=parsed_response["linux"]["minor"],
|
||||
patch=parsed_response["linux"]["releaseNum"],
|
||||
build=parsed_response["linux"]["build"],
|
||||
beta=-1 if parsed_response["linux"]["beta"] is None else parsed_response["linux"]["beta"]
|
||||
), parsed_response["linux"]["releaseId"], parsed_response["linux"]["downloadId"])
|
||||
|
||||
|
||||
def download_using_id(download_id: str, refer_id: str = "77ef91f67a9e411bbbe299e595b4cfcc"):
|
||||
download_url_data = {
|
||||
"firstname": "Flatpak",
|
||||
"lastname": "Builder",
|
||||
"email": "someone@flathub.org",
|
||||
"phone": "202-555-0194",
|
||||
"country": "us",
|
||||
"state": "New York",
|
||||
"city": "FPK",
|
||||
"product": "DaVinci Resolve"
|
||||
}
|
||||
|
||||
download_url_response = requests.post(
|
||||
'https://www.blackmagicdesign.com/api/register/us/download/' + download_id,
|
||||
cookies=cookies,
|
||||
headers={
|
||||
**headers,
|
||||
"Referer": "https://www.blackmagicdesign.com/support/download/" + refer_id + "/Linux",
|
||||
},
|
||||
data=json.dumps(download_url_data),
|
||||
)
|
||||
|
||||
download_url = download_url_response.content.decode('utf-8')
|
||||
|
||||
|
||||
download_reponse = requests.get(download_url, stream=True)
|
||||
with open("./resolve.zip", "wb") as f:
|
||||
for chunk in download_reponse.iter_content(chunk_size=32*1024):
|
||||
f.write(chunk)
|
||||
|
||||
print("Extracting resolve installation...")
|
||||
with zipfile.ZipFile("./resolve.zip", 'r') as zip_file:
|
||||
zip_file.extractall('resolve')
|
||||
@@ -0,0 +1,10 @@
|
||||
class Version:
|
||||
def __init__(self, major: int, minor: int, patch: int, beta: int, build: int):
|
||||
self.major = major
|
||||
self.minor = minor
|
||||
self.patch = patch
|
||||
self.beta = beta
|
||||
self.build = build
|
||||
|
||||
def __str__(self):
|
||||
return f"""{self.major}.{self.minor}.{self.patch}{"" if self.beta == -1 else f".{self.beta}+{self.build}"}"""
|
||||
Reference in new issue
Block a user