|
31 | 31 | import platform
|
32 | 32 | import traceback
|
33 | 33 | import re
|
| 34 | +import urllib3 |
34 | 35 | from github3 import login
|
35 | 36 | from requests.auth import HTTPBasicAuth
|
36 | 37 | from requests import post, get
|
|
43 | 44 | # Access info class (for version info)
|
44 | 45 | sys.path.append(os.path.join(PATH, 'src', 'classes'))
|
45 | 46 |
|
| 47 | +# Disable SSL warnings |
| 48 | +urllib3.disable_warnings() |
| 49 | + |
46 | 50 |
|
47 | 51 | if __name__ == "__main__":
|
48 | 52 | """Only run this code when directly executing this script. """
|
|
180 | 184 | artifact_path = artifact_path_orig
|
181 | 185 | artifact_base, artifact_ext = os.path.splitext(artifact_name)
|
182 | 186 |
|
183 |
| - if os.path.exists(artifact_path) and artifact_ext in ['.exe', '.dmg', '.AppImage', '.torrent', |
| 187 | + if artifact_ext == '.torrent': |
| 188 | + # Delete torrent and continue (we'll recreate the torrents below when needed) |
| 189 | + # The artifact torrents have the incorrect URL inside them |
| 190 | + os.unlink(artifact_path) |
| 191 | + continue |
| 192 | + |
| 193 | + if os.path.exists(artifact_path) and artifact_ext in ['.exe', '.dmg', '.AppImage', |
184 | 194 | '.verify', '.sha256sum']:
|
185 | 195 | # Valid artifact/installer - Upload to GitHub Release
|
186 | 196 | output("GitHub: Uploading %s to GitHub Release: %s" % (artifact_path, github_release.tag_name))
|
187 | 197 | download_url = upload(artifact_path, github_release)
|
188 | 198 |
|
189 |
| - # Create shasum for installer |
190 |
| - if not artifact_name.endswith(".torrent"): |
| 199 | + # Create shasum and torrents for installers-only |
| 200 | + if artifact_ext in ['.exe', '.dmg', '.AppImage']: |
191 | 201 | output("Generating file hash for %s" % artifact_path)
|
192 | 202 | shasum_output = ''
|
193 | 203 | for line in run_command('shasum -a 256 "%s"' % artifact_name, artifact_dir):
|
|
230 | 240 | f.write(' %s: OK' % artifact_name)
|
231 | 241 | upload(sha256sum_instructions_path, github_release)
|
232 | 242 |
|
| 243 | + # Create torrent and upload |
| 244 | + torrent_path = "%s.torrent" % artifact_path |
| 245 | + torrent_command = 'mktorrent -a "udp://tracker.openbittorrent.com:80/announce, udp://tracker.publicbt.com:80/announce, udp://tracker.opentrackr.org:1337" -c "OpenShot Video Editor %s" -w "%s" -o "%s" "%s"' % (github_release.tag_name, download_url, "%s.torrent" % artifact_name, artifact_name) |
| 246 | + torrent_output = "" |
| 247 | + for line in run_command(torrent_command, artifact_dir): |
| 248 | + output(line) |
| 249 | + if line: |
| 250 | + torrent_output = line.decode('UTF-8').strip() |
| 251 | + |
| 252 | + if not torrent_output.endswith("Writing metainfo file... done."): |
| 253 | + # Torrent failed |
| 254 | + raise Exception("Failed to create .torrent for %s" % download_url) |
| 255 | + else: |
| 256 | + # Torrent succeeded! Upload the torrent to github |
| 257 | + url = upload(torrent_path, github_release) |
| 258 | + |
233 | 259 | # Submit blog post (if it doesn't already exist) (in draft mode)
|
234 | 260 | auth = HTTPBasicAuth(os.getenv('OPENSHOT_ORG_USER'), os.getenv('OPENSHOT_ORG_PASS'))
|
235 | 261 | r = post("https://www.openshot.org/api/release/submit/", auth=auth, data={ "version": github_release.tag_name,
|
|
0 commit comments