Merge pull request #15 from McCrafterIV/main

Project restructure, python implementation and bug fixes
This commit is contained in:
Pob authored and GitHub committed 2023-06-08 21:35:10 -07:00
commit 0559b30329
18 files changed
+296 -249

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
build-dir
.idea
venv
repo
.flatpak-builder
+3
View File
@@ -54,3 +54,6 @@ curl -o- https://www.blackmagicdesign.com/api/support/nz/downloads.json |
| [.urls["Linux"][0].downloadTitle, .urls["Linux"][0].downloadId] | [.urls["Linux"][0].downloadTitle, .urls["Linux"][0].downloadId]
| @tsv' | @tsv'
``` ```
## Licensing
The icon in logo.png is licensed under the Creative [Commons Attribution-Share Alike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/deed.en) and fetched from [Wikimedia Commons](https://commons.wikimedia.org/wiki/File:DaVinci_Resolve_Studio.png). It was only cropped afterwards.
-107
View File
@@ -1,107 +0,0 @@
#!/bin/bash
#
# I should probably be a python script.
###
STUDIO='false'
usage()
{
echo "Usage: $0 [ -s | --studio ]"
exit 2
}
PARSED_ARGUMENTS=$(getopt -a -n setup_resolve.sh -o sp: --long studio,prefix: -- "$@")
VALID_ARGUMENTS=$?
if [ "$VALID_ARGUMENTS" != "0" ]; then
usage
fi
eval set -- "$PARSED_ARGUMENTS"
while :
do
case "$1" in
-s | --studio) STUDIO='true' ; shift ;;
--) shift; break ;;
*) echo "Unexpected option: $1 - this should not happen."
usage ;;
esac
done
APP_ID="com.blackmagic.Resolve"
APP_DESCRIPTION="DaVinci Resolve"
APP_TAG="davinci-resolve"
if ${STUDIO}; then
APP_ID="com.blackmagic.ResolveStudio"
APP_DESCRIPTION="DaVinci Resolve Studio"
APP_TAG="davinci-resolve-studio"
fi
mkdir -p /app/share/metainfo
chmod 755 /app/share/metainfo
cat > /app/share/metainfo/${APP_ID}.metainfo.xml <<EOF
<?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>
DaVinci Resolve is the world’s only solution that combines editing, color correction, visual effects, motion graphics and audio post production all in one software tool! Its elegant, modern interface is fast to learn and easy for new users, yet powerful for professionals. DaVinci Resolve lets you work faster and at a higher quality because you don’t have to learn multiple apps or switch software for different tasks. That means you can work with camera original quality images throughout the entire process. It’s like having your own post production studio in a single app! Best of all, by learning DaVinci Resolve, you’re learning how to use the exact same tools used by Hollywood professionals!
</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>
EOF
curl -o- https://www.blackmagicdesign.com/api/support/nz/downloads.json |
jq --arg APP_TAG "${APP_TAG}" -r '
def url_linux: .urls["Linux"][0];
.downloads[] |
select(.urls["Linux"] != null) |
select(.urls["Linux"][0]["product"] == $APP_TAG) |
" <release version=\"" + (.urls["Linux"][0].major|tostring) + "." + (.urls["Linux"][0].minor|tostring) + "." + (.urls["Linux"][0].releaseNum|tostring) + "~" + (.numericDate|tostring) + "\" date=\"" + (.numericDate / 1000|strftime("%Y-%m-%d")) + "\">",
" <description>",
.desc,
" </description>",
" </release>"
' >> /app/share/metainfo/${APP_ID}.metainfo.xml
cat >> /app/share/metainfo/${APP_ID}.metainfo.xml <<EOF
</releases>
</component>
EOF
+5
View File
@@ -0,0 +1,5 @@
[Desktop Entry]
Type=Application
Name=Davinci Resolve
Icon=com.blackmagic.Resolve
Exec=/app/bin/resolve.sh
+21 -8
View File
@@ -28,17 +28,30 @@ modules:
build-args: build-args:
- --share=network - --share=network
build-commands: build-commands:
- install -Dm644 logo.png /app/share/icons/hicolor/scalable/apps/com.blackmagic.Resolve.png
- install -Dm644 com.blackmagic.Resolve.desktop /app/share/applications/com.blackmagic.Resolve.desktop
- | - |
./download_resolve.sh -p davinci-resolve ./run_complete_installation.sh
./setup_resolve.sh
./appdata.sh
install -Dm755 resolve.sh /app/bin/resolve.sh
sources: sources:
- type: file - type: file
path: download_resolve.sh path: python/build_metainfo.py
- type: file - type: file
path: setup_resolve.sh path: python/main.py
- type: file - type: file
path: appdata.sh path: python/resolve_download.py
- type: file - type: file
path: resolve.sh path: python/version.py
- type: file
path: shell/setup_resolve.sh
- type: file
path: shell/setup_directories.sh
- type: file
path: shell/resolve.sh
- type: file
path: run_complete_installation.sh
- type: file
path: requirements.txt
- type: file
path: logo.png
- type: file
path: com.blackmagic.Resolve.desktop
+5
View File
@@ -0,0 +1,5 @@
[Desktop Entry]
Type=Application
Name=Davinci Resolve Studio
Icon=com.blackmagic.ResolveStudio
Exec=/app/bin/resolve.sh
+21 -8
View File
@@ -28,17 +28,30 @@ modules:
build-args: build-args:
- --share=network - --share=network
build-commands: build-commands:
- install -Dm644 logo.png /app/share/icons/hicolor/scalable/apps/com.blackmagic.ResolveStudio.png
- install -Dm644 com.blackmagic.ResolveStudio.desktop /app/share/applications/com.blackmagic.ResolveStudio.desktop
- | - |
./download_resolve.sh -p davinci-resolve-studio ./run_complete_installation.sh --studio
./setup_resolve.sh -s
./appdata.sh -s
install -Dm755 resolve.sh /app/bin/resolve.sh
sources: sources:
- type: file - type: file
path: download_resolve.sh path: python/build_metainfo.py
- type: file - type: file
path: setup_resolve.sh path: python/main.py
- type: file - type: file
path: appdata.sh path: python/resolve_download.py
- type: file - type: file
path: resolve.sh path: python/version.py
- type: file
path: shell/setup_resolve.sh
- type: file
path: shell/setup_directories.sh
- type: file
path: shell/resolve.sh
- type: file
path: run_complete_installation.sh
- type: file
path: requirements.txt
- type: file
path: logo.png
- type: file
path: com.blackmagic.ResolveStudio.desktop
-126
View File
@@ -1,126 +0,0 @@
#!/bin/sh
#
# By default, the script in here will download the latest version of DaVinci Resolve.
#
# Use the following to get a full list of download IDs from Blackmagic:
#curl -o- https://www.blackmagicdesign.com/api/support/nz/downloads.json | jq -r '.downloads[] | select(.urls["Linux"] != null) | select(.urls["Linux"][0]["product"] == "davinci-resolve-studio") | [.urls["Linux"][0].downloadTitle, .urls["Linux"][0].downloadId] | @tsv'
# or:
#curl -o- https://www.blackmagicdesign.com/api/support/nz/downloads.json | jq -r '.downloads[] | select(.urls["Linux"] != null) | select(.urls["Linux"][0]["product"] == "davinci-resolve") | [.urls["Linux"][0].downloadTitle, .urls["Linux"][0].downloadId] | @tsv'
#DaVinci Resolve 18.1.4 6449dc76e0b845bcb7399964b00a3ec4
#DaVinci Resolve 18.1.3 44be7e694b4e440db5d2f70ad732d3b2
#DaVinci Resolve 18.1.2 4755b7bd2d924c0db1980824edb84a20
#DaVinci Resolve 18.1.1 e09749f2de1d4c20a2b707c405d243fd
####
PRODUCT='davinci-resolve'
SITEURL='https://www.blackmagicdesign.com/api/support/latest-version'
REFERID='77ef91f67a9e411bbbe299e595b4cfcc'
USERAGENT="User-Agent: Mozilla/5.0 (X11; Linux ${CARCH}) \
AppleWebKit/537.36 (KHTML, like Gecko) \
Chrome/77.0.3865.75 \
Safari/537.36"
# e.g. DOWNLOADID='44be7e694b4e440db5d2f70ad732d3b2'
DOWNLOADID=''
####
#
# Process arguments
#
####
usage()
{
echo "Usage: $0 [ -p | --product PRODUCT ] [ -d | --downloadid DOWNLOADID ]"
echo ""
echo "PRODUCT is davinci-resolve or davinci-resolve-studio"
exit 2
}
PARSED_ARGUMENTS=$(getopt -a -n download_resolve.sh -o d:p: --long download:,product: -- "$@")
VALID_ARGUMENTS=$?
if [ "$VALID_ARGUMENTS" != "0" ]; then
usage
fi
eval set -- "$PARSED_ARGUMENTS"
while :
do
case "$1" in
-p | --prefix) PRODUCT="$2" ; shift 2 ;;
-d | --downloadid) DOWNLOADID="$2" ; shift 2 ;;
--) shift; break ;;
*) echo "Unexpected option: $1 - this should not happen."
usage ;;
esac
done
####
#
# Find a download link
#
####
USERAGENT="$(printf '%s' "$USERAGENT" | sed 's/[[:space:]]\+/ /g')"
# The following will find the latest version of Resolve/Resolve Studio.
REQJSON="{ \
\"product\": \"${PRODUCT}\", \
\"platform\": \"linux\" \
}"
REQJSON="$( printf '%s' "$REQJSON" | sed 's/[[:space:]]\+/ /g')"
if [ -z "${DOWNLOADID}" ]; then
DOWNLOADID="$(curl \
-s \
-H 'Host: www.blackmagicdesign.com' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Origin: https://www.blackmagicdesign.com' \
-H "$USERAGENT" \
-H 'Content-Type: application/json;charset=UTF-8' \
-H "Referer: https://www.blackmagicdesign.com/support/download/${REFERID}/Linux" \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Accept-Language: en-US,en;q=0.9' \
-H 'Authority: www.blackmagicdesign.com' \
-H 'Cookie: _ga=GA1.2.1849503966.1518103294; _gid=GA1.2.953840595.1518103294' \
--data-ascii "$REQJSON" \
--compressed \
"$SITEURL" | jq -r '.["linux"]["downloadId"]')"
fi
REQJSON="{ \
\"firstname\": \"Flatpak\", \
\"lastname\": \"Builder\", \
\"email\": \"someone@flathub.org\", \
\"phone\": \"202-555-0194\", \
\"country\": \"us\", \
\"state\": \"New York\", \
\"city\": \"FPK\", \
\"product\": \"DaVinci Resolve\" \
}"
REQJSON="$( printf '%s' "$REQJSON" | sed 's/[[:space:]]\+/ /g')"
SITEURL="https://www.blackmagicdesign.com/api/register/us/download/${DOWNLOADID}"
SRCURL="$(curl \
-s \
-H 'Host: www.blackmagicdesign.com' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Origin: https://www.blackmagicdesign.com' \
-H "$USERAGENT" \
-H 'Content-Type: application/json;charset=UTF-8' \
-H "Referer: https://www.blackmagicdesign.com/support/download/${REFERID}/Linux" \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'Accept-Language: en-US,en;q=0.9' \
-H 'Authority: www.blackmagicdesign.com' \
-H 'Cookie: _ga=GA1.2.1849503966.1518103294; _gid=GA1.2.953840595.1518103294' \
--data-ascii "$REQJSON" \
--compressed \
"${SITEURL}")"
FNAME="$(curl \
--no-clobber \
-gqb '' -C - --retry 3 --retry-delay 3 \
-H 'Host: sw.blackmagicdesign.com' \
-H 'Upgrade-Insecure-Requests: 1' \
-H "${USERAGENT}" \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8' \
-H 'Accept-Language: en-US,en;q=0.9' \
-w '%{filename_effective}' \
--compressed \
-O \
${SRCURL})"
unzip -x "${FNAME}"
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

+99
View File
@@ -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)
+25
View File
@@ -0,0 +1,25 @@
import sys
from resolve_download import *
if __name__ == "__main__":
is_studio = '--studio' in sys.argv
is_beta = '--beta' in sys.argv
app_tag = "davinci-resolve-studio" if is_studio else "davinci-resolve"
print("Building for tag " + app_tag)
print("Requesting version information...")
(version, release_id, download_id) = get_latest_version_information(
refer_id='77ef91f67a9e411bbbe299e595b4cfcc',
app_tag=app_tag,
stable=is_beta is False,
)
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,
# )
+87
View File
@@ -0,0 +1,87 @@
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', stable=True):
response: requests.Response = requests.get(
f"https://www.blackmagicdesign.com/api/support/latest-stable-version/{app_tag}/linux"
if stable else
f"https://www.blackmagicdesign.com/api/support/latest-version/{app_tag}/linux",
cookies=cookies,
headers={
**headers,
'Referer': 'https://www.blackmagicdesign.com/support/download/' + refer_id + '/Linux',
},
)
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=parsed_response["linux"]["beta"] if "beta" in parsed_response["linux"] else -1
), 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_response = requests.get(download_url, stream=True)
total_size_in_bytes = int(download_response.headers.get('Content-Length', 0))
progress = 0
with open("./resolve.zip", "wb") as f:
for chunk in download_response.iter_content(chunk_size=32 * 1024):
f.write(chunk)
progress += len(chunk)
print(" " + str(round(progress / total_size_in_bytes * 100, 4)) + "%")
print("Extracting resolve installation...")
with zipfile.ZipFile("./resolve.zip", 'r') as zip_file:
zip_file.extractall('.')
+10
View File
@@ -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}"}"""
+1
View File
@@ -0,0 +1 @@
requests
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
echo "Setting up python build environment..."
python -m venv venv
source ./venv/bin/activate
pip3 install -r requirements.txt
echo "Setting up directory structure..."
./setup_directories.sh $1
python3 ./main.py $1
chmod +x ./DaVinci_Resolve_*_Linux.run
./setup_resolve.sh
install -Dm755 resolve.sh /app/bin/resolve.sh
View File
File renamed without changes.
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
mkdir -p /app/share/metainfo
chmod 755 /app/share/metainfo
File renamed without changes.