text
stringlengths
0
15.7k
source
stringlengths
6
112
set URL_user_entered_clean_quoted to ""
Main.applescript
repeat with current_URL in text items of URL_user_entered_clean
Main.applescript
set current_URL to "'" & current_URL & "'"
Main.applescript
set URL_user_entered_clean_quoted to URL_user_entered_clean_quoted & current_URL & " "
Main.applescript
set URL_user_entered_clean_quoted to quoted form of URL_user_entered_clean
Main.applescript
set YTDL_no_playlist to ""
Main.applescript
set playlist_Name to ""
Main.applescript
set DL_Playlist_Items_Spec to ""
Main.applescript
set alerterPiD to ""
Main.applescript
if DL_Custom_Settings contains "playlist-items" or DL_Custom_Settings contains "-I" then
Main.applescript
set num_custom_settings_items to count of text items in DL_Custom_Settings
Main.applescript
repeat with i from 1 to num_custom_settings_items
Main.applescript
if text item (i) of DL_Custom_Settings is "-I" or text item (i) of DL_Custom_Settings is "--playlist-items" then
Main.applescript
set DL_Playlist_Items_Spec to ("--playlist-items " & text item (i + 1) of DL_Custom_Settings & " ")
Main.applescript
if URL_user_entered_clean contains "&index=" and URL_user_entered_clean contains "youtu" then
Main.applescript
set YTDL_no_playlist to "--no-playlist "
Main.applescript
else if URL_user_entered_clean contains "playlist" or (URL_user_entered_clean contains "watch?" and URL_user_entered_clean contains "&list=") or (URL_user_entered_clean contains "?list=") then
Main.applescript
set playListAlertActionLabel to quoted form of "_"
Main.applescript
set playListAlertTitle to quoted form of (localized string "MacYTDL" from table "MacYTDL")
Main.applescript
set playListAlertMessage to quoted form of (localized string " Please wait." from table "MacYTDL")
Main.applescript
set playListAlertSubtitle to quoted form of (localized string "Now checking detail of playlist. " from table "MacYTDL")
Main.applescript
set alerterPiD to do shell script quoted form of (resourcesPath & "alerter") & " -message " & playListAlertMessage & " -title " & playListAlertTitle & " -subtitle " & playListAlertSubtitle & " -sender com.apple.script.id.MacYTDL -actions " & playListAlertActionLabel & " -timeout 10 > /dev/null 2> /dev/null & echo $!"
Main.applescript
set playlist_Simulate to do shell script shellPath & "cd " & quoted form of downloadsFolder_Path & " ; " & DL_Use_YTDLP & " --flat-playlist " & DL_Playlist_Items_Spec & YTDL_Use_Cookies & URL_user_entered_clean_quoted
Main.applescript
on error error_Message
Main.applescript
do shell script "kill " & alerterPiD
Main.applescript
set theErrorWithPlaylistLabel1 to "There was an error with the playlist. The error was: \""
Main.applescript
if DL_Use_Cookies is true and error_Message contains "playlist does not exist" then
Main.applescript
set theErrorWithPlaylistLabel2 to "This may have been caused by a faulty cookies file. Check the file and try again."
Main.applescript
set theErrorWithPlaylistLabel2 to "Check the URL and try again."
Main.applescript
display dialog theErrorWithPlaylistLabel1 & error_Message & "\" " & theErrorWithPlaylistLabel2 buttons {theButtonReturnLabel} default button 1 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600
Main.applescript
set AppleScript's text item delimiters to {"[download] Downloading playlist: ", return & "[youtube:tab] Playlist "}
Main.applescript
set playlist_Name to text item 2 of playlist_Simulate
Main.applescript
if playlist_Name contains "/" then
Main.applescript
set playlist_Name to run_Utilities_handlers's replace_chars(playlist_Name, "/", "_")
Main.applescript
set AppleScript's text item delimiters to {": Downloading ", " videos"}
Main.applescript
if (URL_user_entered_clean contains "list=PL" or URL_user_entered_clean contains "list=OL") and (URL_user_entered_clean contains "watch?" or URL_user_entered_clean contains "//youtu.be/") then
Main.applescript
set playlist_Number_Items to text item 4 of playlist_Simulate as integer
Main.applescript
set playlist_Number_Items to text item 3 of playlist_Simulate as integer
Main.applescript
repeat with x from 1 to count paragraphs of playlist_Simulate
Main.applescript
if contents of paragraph x of playlist_Simulate begins with "[youtube:tab] Playlist" then
Main.applescript
set PL_simulate_Paragraph to paragraph (x) of playlist_Simulate
Main.applescript
set AppleScript's text item delimiters to {": Downloading ", " items "}
Main.applescript
set playlist_Number_Items to text item 2 of PL_simulate_Paragraph as integer
Main.applescript
if playlist_Number_Items is greater than 20 then
Main.applescript
if alerterPiD is not "" then do shell script "kill " & alerterPiD
Main.applescript
set theManyPlaylistItemsLabel1 to localized string "There are " from table "MacYTDL"
Main.applescript
set theManyPlaylistItemsLabel2 to localized string " items in playlist " from table "MacYTDL"
Main.applescript
set theManyPlaylistItemsLabel3 to localized string "It will take a long time to download. Do you wish to continue or return to the Main dialog ?" from table "MacYTDL"
Main.applescript
set quit_or_return to button returned of (display dialog theManyPlaylistItemsLabel1 & playlist_Number_Items & theManyPlaylistItemsLabel2 & "\"" & playlist_Name & "\". " & theManyPlaylistItemsLabel3 buttons {theButtonReturnLabel, theButtonContinueLabel} default button 2 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600)
Main.applescript
if playlist_Name is "" and DL_Use_YTDLP is "yt-dlp" and is_channel is true then
Main.applescript
set playListAlertSubtitle to quoted form of (localized string "Now checking detail of channel. " from table "MacYTDL")
Main.applescript
set theErrorWithPlaylistLabel1 to "There was an error with the channel. The error was: \""
Main.applescript
if DL_Use_Cookies is true and error_Message contains "channel does not exist" then
Main.applescript
if (contents of paragraph x of playlist_Simulate contains " - Videos: Downloading ") or (contents of paragraph x of playlist_Simulate contains " - Topic: Downloading ") then
Main.applescript
set playlist_details to paragraph (x) of playlist_Simulate
Main.applescript
set AppleScript's text item delimiters to {"[youtube:tab] Playlist ", " - Videos: Downloading ", " - Topic: Downloading "}
Main.applescript
set playlist_Name to text item 2 of playlist_details
Main.applescript
set AppleScript's text item delimiters to {" "}
Main.applescript
set playlist_Number_Items to last text item of playlist_details as integer
Main.applescript
set theManyPlaylistItemsLabel2 to localized string " items in channel " from table "MacYTDL"
Main.applescript
if number_of_URLs is greater than 1 and DL_formats_list is true then
Main.applescript
set theTooManyUELsLabel to localized string "Sorry, but MacYTDL cannot list formats for more than one URL. Would you like to cancel the download and return to the main dialog or skip the formats list and continue to download ?" from table "MacYTDL"
Main.applescript
set skip_or_return to button returned of (display dialog theTooManyUELsLabel buttons {theButtonReturnLabel, theButtonContinueLabel} default button 2 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600)
Main.applescript
if skip_or_return is theButtonReturnLabel then
Main.applescript
if playlist_Name is not "" and DL_formats_list is true then
Main.applescript
set thePlaylistAndListLabel to localized string "Sorry, but MacYTDL cannot list formats for playlists. Would you like to cancel the download and return to the main dialog or skip the formats list and continue to download ?" from table "MacYTDL"
Main.applescript
set skip_or_return to button returned of (display dialog thePlaylistAndListLabel buttons {theButtonReturnLabel, theButtonContinueLabel} default button 2 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600)
Main.applescript
if is_channel is true and DL_formats_list is true then
Main.applescript
set thePlaylistAndListLabel to localized string "Sorry, but MacYTDL cannot list formats for channels. Would you like to cancel the download and return to the main dialog or skip the formats list and continue to download ?" from table "MacYTDL"
Main.applescript
set simulate_YTDL_output_template to run_Utilities_handlers's replace_chars(YTDL_output_template, " -o '%", " -o '%(is_live)s#%")
Main.applescript
do shell script shellPath & "cd " & quoted form of downloadsFolder_Path & " ; export LC_CTYPE=UTF-8 ; " & DL_Use_YTDLP & " --get-filename --ignore-errors " & YTDL_format_pref & DL_Playlist_Items_Spec & YTDL_credentials & YTDL_Use_Proxy & YTDL_Use_Cookies & YTDL_no_playlist & simulate_YTDL_output_template & " " & URL_user_entered_clean_quoted & " 2>&1 &>" & YTDL_simulate_file & " ; exit 0"
Main.applescript
set YTDL_simulate_log to read POSIX file YTDL_simulate_file as «class utf8»
Main.applescript
on error errmsg
Main.applescript
display dialog "Error in reading simulate file: " & YTDL_simulate_file & return & "The error reported was " & errmsg
Main.applescript
set is_Livestream_Flag to "False"
Main.applescript
if playlist_Name is "" then
Main.applescript
if YTDL_simulate_log contains "True#" then
Main.applescript
set is_Livestream_Flag to "True"
Main.applescript
set YTDL_no_part to "--no-part "
Main.applescript
if (length of YTDL_simulate_log is greater than 195) and ((count of paragraphs in YTDL_simulate_log) is less than 3) then
Main.applescript
set theFileNameTooLongLabel to localized string "With your custom file name output template, the total length of the log file name is too long. Would you like to exclude your custom template then continue or return to Main ?" from table "MacYTDL"
Main.applescript
set quit_or_return to button returned of (display dialog theFileNameTooLongLabel buttons {theButtonReturnLabel, theButtonContinueLabel} default button 2 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600)
Main.applescript
set YTDL_output_template to " -o '%(is_live)s#%(title)s.%(ext)s'"
Main.applescript
do shell script shellPath & "cd " & quoted form of downloadsFolder_Path & " ; export LC_CTYPE=UTF-8 ; " & DL_Use_YTDLP & " --get-filename --ignore-errors " & YTDL_no_playlist & DL_Playlist_Items_Spec & YTDL_format_pref & YTDL_credentials & YTDL_Use_Proxy & YTDL_Use_Cookies & simulate_YTDL_output_template & " " & URL_user_entered_clean_quoted & " 2>&1 &>" & YTDL_simulate_file & " ; exit 0"
Main.applescript
if YTDL_simulate_log contains "#NA-" and (URL_user_entered contains "ABC" or URL_user_entered contains "ITV" or URL_user_entered contains "7Plus") then
Main.applescript
set YTDL_simulate_log to run_Utilities_handlers's replace_chars(YTDL_simulate_log, "NA-", "") -- Removes placeholder when there is no series name - put there by output template for ABC, ITV & 7Plus
Main.applescript
if YTDL_simulate_log contains "Unsupported URL: https://7Plus.com.au" then
Main.applescript
set theURLWarning7PlusLabel to localized string "This is a 7Plus Show page from which MacYTDL cannot download videos. Try an individual episode." from table "MacYTDL"
Main.applescript
display dialog theURLWarning7PlusLabel with title diag_Title buttons {theButtonOKLabel} default button 1 with icon file MacYTDL_custom_icon_file giving up after 600
Main.applescript
if YTDL_simulate_log contains "Unsupported URL: https://www.9now.com.au" then
Main.applescript
set theURLWarning9NowLabel to localized string "This is a 9Now Show page from which MacYTDL cannot download videos. Try an individual episode." from table "MacYTDL"
Main.applescript
display dialog theURLWarning9NowLabel with title diag_Title buttons {theButtonOKLabel} default button 1 with icon file MacYTDL_custom_icon_file giving up after 600
Main.applescript
if YTDL_simulate_log contains "Unsupported URL: https://10play.com.au" then
Main.applescript
set theURLWarning10playLabel to localized string "This is a 10Play Show page from which MacYTDL cannot download videos. Try an individual episode." from table "MacYTDL"
Main.applescript
display dialog theURLWarning10playLabel with title diag_Title buttons {theButtonOKLabel} default button 1 with icon file MacYTDL_custom_icon_file giving up after 600
Main.applescript
if YTDL_simulate_log contains "requested format not available" then
Main.applescript
set theFormatNotAvailLabel1 to localized string "Your preferred file format is not available. Would you like to cancel download and return, have your download remuxed into your preferred format or just download the best format available ?" from table "MacYTDL"
Main.applescript
set theFormatNotAvailLabel2 to localized string "{Note: 3gp format is not available - a request for 3gp will be remuxed into mp4.}" from table "MacYTDL"
Main.applescript
set theFormatNotAvailButtonRemuxLabel to localized string "Remux" from table "MacYTDL"
Main.applescript
set quit_or_return to button returned of (display dialog theFormatNotAvailLabel1 & return & theFormatNotAvailLabel2 buttons {theButtonReturnLabel, theFormatNotAvailButtonRemuxLabel, theButtonDownloadLabel} default button 3 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600)
Main.applescript