Skip to content

Commit cf3c10a

Browse files
authored
DRAFT - for forthcoming release of v1.30
1 parent 0dea820 commit cf3c10a

File tree

7 files changed

+9513
-0
lines changed

7 files changed

+9513
-0
lines changed

Code/Auto_download.applescript

Lines changed: 2703 additions & 0 deletions
Large diffs are not rendered by default.

Code/Formats.applescript

Lines changed: 401 additions & 0 deletions
Large diffs are not rendered by default.

Code/Main.applescript

Lines changed: 4255 additions & 0 deletions
Large diffs are not rendered by default.

Code/Monitor.applescript

Lines changed: 1151 additions & 0 deletions
Large diffs are not rendered by default.

Code/Utilities2.applescript

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2+
-- MacYTDL
3+
-- A GUI for the Python Script yt-dlp. Many thanks to Shane Stanley.
4+
-- This is contains utilities for installing components etc.
5+
-- Handlers in this script are called by main.scpt
6+
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
7+
8+
-- Include libraries
9+
use AppleScript version "2.4" -- Yosemite (10.10) or later
10+
use scripting additions
11+
-- use script "DialogToolkitMacYTDL" -- probably don't need DTP
12+
property parent : AppleScript
13+
14+
15+
--------------------------------------------------------------------------
16+
-- for testing
17+
--set deno_version to "2.5.4"
18+
--set user_system_arch to "arm64"
19+
--set path_to_MacYTDL to path to me as text
20+
--set resourcesPath to POSIX path of (path_to_MacYTDL & "Contents:Resources:")
21+
--set theButtonOKLabel to "OK"
22+
--set MacYTDL_custom_icon_file to "Bennett:Users:macytdl:MacYTDL:MacYTDL:MacYTDL.app:Contents:Resources:macytdl.icns" as string
23+
--set diag_Title to "MacYTDL, v1.30 - testing"
24+
--install_update_Deno(deno_version, user_system_arch, resourcesPath, path_to_MacYTDL, theButtonOKLabel, MacYTDL_custom_icon_file, diag_Title)
25+
--------------------------------------------------------------------------
26+
27+
--------------------------------------------------------------------------
28+
--
29+
-- Does user wish to install/update Deno ?
30+
--
31+
--------------------------------------------------------------------------
32+
33+
-- Handler for installing/updating Deno - called by Preliminaries and Utilities dialog - Added in v1.30, 1/11/25
34+
-- Assuming for now that Deno version number is sourced from Preliminaries, before main_dialog()
35+
-- deno_version contains current version installed or "Not installed"
36+
-- Currently sourcing Deno from deno.land. If there are problems will change to GitHub.
37+
on install_update_Deno(deno_version, user_system_arch, resourcesPath, path_to_MacYTDL, theButtonOKLabel, MacYTDL_custom_icon_file, diag_Title)
38+
-- Result of next line will be formatted like "v2.5.6" - so we add the leading v character to deno_version
39+
set deno_current_version to do shell script "curl -s https://dl.deno.land/release-latest.txt"
40+
if deno_current_version is not ("v" & deno_version) then
41+
if user_system_arch is "Intel" then
42+
set deno_download_site to "https://dl.deno.land/release/" & deno_current_version & "/deno-x86_64-apple-darwin.zip"
43+
-- set deno_download_site to "https://github.com/denoland/deno/releases/download/" & deno_current_version & "/deno-x86_64-apple-darwin.zip"
44+
else
45+
set deno_download_site to "https://dl.deno.land/release/" & deno_current_version & "/deno-aarch64-apple-darwin.zip"
46+
-- set deno_download_site to "https://github.com/denoland/deno/releases/download/" & deno_current_version & "/deno-aarch64-apple-darwin.zip"
47+
end if
48+
set installAlertActionLabel to quoted form of "_"
49+
set installAlertTitle to quoted form of (localized string "MacYTDL installation:" from table "MacYTDL")
50+
set installAlertMessage to quoted form of (localized string "started. Please wait." from table "MacYTDL")
51+
set installAlertSubtitle to quoted form of (localized string "Installing Deno" from table "MacYTDL")
52+
do shell script resourcesPath & "alerter -message " & installAlertMessage & " -title " & installAlertTitle & " -subtitle " & installAlertSubtitle & " -timeout 10 -sender com.apple.script.id.MacYTDL -actions " & installAlertActionLabel & " > /dev/null 2> /dev/null & "
53+
try
54+
do shell script "curl -L " & deno_download_site & " -o /usr/local/bin/deno.zip" with administrator privileges
55+
do shell script "unzip -o /usr/local/bin/deno.zip -d /usr/local/bin/" with administrator privileges
56+
do shell script "rm /usr/local/bin/deno.zip" with administrator privileges
57+
set deno_version to text 2 thru end of deno_current_version
58+
display dialog ((localized string "Deno is installed and up-to-date. You have version ") & deno_version) buttons {theButtonOKLabel} default button 1 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600
59+
on error number -128
60+
-- User cancels credentials dialog - just return to Main dialog
61+
set theYTDLInstallCancelLabel to localized string "You've cancelled installing Deno. You can install/update Deno in the Utilities dialog." in bundle file path_to_MacYTDL from table "MacYTDL"
62+
display dialog theYTDLInstallCancelLabel buttons {theButtonOKLabel} default button 1 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600
63+
end try
64+
else
65+
display dialog ((localized string "Deno is up-to-date. You have version ") & deno_version) buttons {theButtonOKLabel} default button 1 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600
66+
return deno_version
67+
end if
68+
return deno_version
69+
end install_update_Deno

0 commit comments

Comments
 (0)