text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
set theDownloadFolderMissingLabel to localized string "Your download folder is not available. You can make it available then click on Continue, return to set a new download folder or quit." from table "MacYTDL"
|
Main.applescript
|
set quit_or_return to button returned of (display dialog theDownloadFolderMissingLabel buttons {theButtonQuitLabel, theButtonReturnLabel, theButtonContinueLabel} default button 2 cancel button 1 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600)
|
Main.applescript
|
end check_download_folder
|
Main.applescript
|
on set_File_Names(shellPath, YTDL_simulate_log, URL_user_entered, ABC_show_name, SBS_show_name, DL_Use_YTDLP)
|
Main.applescript
|
set num_paragraphs_log to count of paragraphs of YTDL_simulate_log
|
Main.applescript
|
set number_of_URLs to number of text items in URL_user_entered
|
Main.applescript
|
if ABC_show_name is "" and SBS_show_name is "" then -- not an ABC or SBS show page
|
Main.applescript
|
if number_of_URLs is 1 then -- Single file download or playlist
|
Main.applescript
|
set download_filename to YTDL_simulate_log
|
Main.applescript
|
if YTDL_simulate_log does not contain "WARNING:" and YTDL_simulate_log does not contain "ERROR:" then --<= A single file or playlist download non-error and non-warning (iView and non-iView)
|
Main.applescript
|
if num_paragraphs_log is 2 then --<= A single file download (iView and non-iView) - need to trim ".mp4<para>" from end of file (which is a single line containing one file name)
|
Main.applescript
|
if YTDL_simulate_log contains "/" then
|
Main.applescript
|
set offsetOfLastSlash to last_offset(YTDL_simulate_log, "/") + 2
|
Main.applescript
|
set download_filename_only to text offsetOfLastSlash thru -2 of YTDL_simulate_log
|
Main.applescript
|
set download_filename_trimmed to text offsetOfLastSlash thru ((YTDL_simulate_log's length) - (offset of "." in (the reverse of every character of YTDL_simulate_log) as text)) of YTDL_simulate_log
|
Main.applescript
|
set download_filename_only to text 1 thru -2 of YTDL_simulate_log
|
Main.applescript
|
set download_filename_trimmed to text 1 thru ((YTDL_simulate_log's length) - (offset of "." in (the reverse of every character of YTDL_simulate_log) as text)) of YTDL_simulate_log
|
Main.applescript
|
set download_filename_trimmed to run_Utilities_handlers's replace_chars(download_filename_trimmed, " ", "_")
|
Main.applescript
|
set download_filename_new to run_Utilities_handlers's replace_chars(download_filename_only, " ", "_")
|
Main.applescript
|
set YTDL_log_file to MacYTDL_preferences_path & "youtube-dl_log-" & download_filename_trimmed & "-" & download_date_time & ".txt"
|
Main.applescript
|
else --<= Probably a Youtube playlist - but beware as there can be playlists on other sites
|
Main.applescript
|
set download_filename_new to playlist_Name
|
Main.applescript
|
set download_filename_new to run_Utilities_handlers's replace_chars(download_filename_new, " ", "_")
|
Main.applescript
|
set download_filename_new to "the-playlist"
|
Main.applescript
|
else if YTDL_simulate_log contains "WARNING:" and YTDL_simulate_log does not contain "ERROR:" then --<= Single file download but simulate.txt contains WARNING(S) (iView and non-iView) - need to trim warning paras and ".mp4<para>" from end of simulate log - but Futurewarning warnings have reverse layout in simulate log
|
Main.applescript
|
if YTDL_simulate_log contains "FutureWarning:" then
|
Main.applescript
|
set YTDL_simulate_log to paragraph 1 of YTDL_simulate_log
|
Main.applescript
|
set numParas to count paragraphs in YTDL_simulate_log
|
Main.applescript
|
set YTDL_simulate_log to paragraph (numParas - 1) of YTDL_simulate_log
|
Main.applescript
|
if text -1 thru -6 of YTDL_simulate_log contains "." then
|
Main.applescript
|
set download_filename_trimmed to download_filename
|
Main.applescript
|
else if YTDL_simulate_log contains "ERROR:" then --<= Single file download or playlist but simulate.txt contains ERROR (iView and non-iView) - need a generic file name for non-playlists
|
Main.applescript
|
set download_filename_new to "the-error-download"
|
Main.applescript
|
else --<= This is a multiple file (iView and non-iView) download - don't distinguish between iView and others - covers warning and non-warning cases
|
Main.applescript
|
set download_filename_new to "the multiple videos"
|
Main.applescript
|
set YTDL_log_file to MacYTDL_preferences_path & "youtube-dl_log-Multiple_download_on-" & download_date_time & ".txt"
|
Main.applescript
|
else if ABC_show_name is not "" then
|
Main.applescript
|
if number_ABC_SBS_episodes is 0 then
|
Main.applescript
|
set download_filename to last paragraph of (do shell script shellPath & "cd " & quoted form of downloadsFolder_Path & " ; export LC_CTYPE=UTF-8 ; " & DL_Use_YTDLP & " --get-filename --ignore-errors " & URL_user_entered & " " & YTDL_output_template)
|
Main.applescript
|
set download_filename_trimmed to text 1 thru ((download_filename's length) - (offset of "." in (the reverse of every character of download_filename) as text)) of download_filename
|
Main.applescript
|
else if number_ABC_SBS_episodes is 1 then
|
Main.applescript
|
set download_filename to text 1 thru -1 of (do shell script shellPath & "cd " & quoted form of downloadsFolder_Path & " ; export LC_CTYPE=UTF-8 ; " & DL_Use_YTDLP & " --get-filename --ignore-errors " & URL_user_entered & " " & YTDL_output_template)
|
Main.applescript
|
set download_filename_trimmed to text 1 thru ((download_filename_new's length) - (offset of "." in (the reverse of every character of download_filename_new) as text)) of download_filename_new
|
Main.applescript
|
set download_filename to text 1 thru -1 of (do shell script shellPath & "cd " & quoted form of downloadsFolder_Path & " ; export LC_CTYPE=UTF-8 ; " & DL_Use_YTDLP & " --get-filename --ignore-errors " & ABC_show_URLs & " " & YTDL_output_template)
|
Main.applescript
|
set ABC_show_name_underscore to run_Utilities_handlers's replace_chars(ABC_show_name, " ", "_")
|
Main.applescript
|
set YTDL_log_file to MacYTDL_preferences_path & "youtube-dl_log-" & ABC_show_name_underscore & "-" & download_date_time & ".txt"
|
Main.applescript
|
else if SBS_show_name is not "" then
|
Main.applescript
|
if number_ABC_SBS_episodes is 1 then
|
Main.applescript
|
if errmsg contains "ERROR: [ThePlatform]" or errmsg contains "HTTP Error 403: Forbidden" then
|
Main.applescript
|
set theSBSsimulateFailedLabel to localized string "Something went wrong trying to download from SBS. The error was: " from table "MacYTDL"
|
Main.applescript
|
display dialog (theSBSsimulateFailedLabel & return & return & errmsg) buttons {theButtonOKLabel} default button 1 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600
|
Main.applescript
|
if YTDL_simulate_log contains "ERROR: Unsupported URL: https://www.sbs.com.au/ondemand" then
|
Main.applescript
|
set download_filename_trimmed to download_filename_new
|
Main.applescript
|
set download_filename to text 1 thru -1 of (do shell script shellPath & "cd " & quoted form of downloadsFolder_Path & " ; export LC_CTYPE=UTF-8 ; " & DL_Use_YTDLP & " --get-filename --ignore-errors " & SBS_show_URLs & " " & YTDL_output_template)
|
Main.applescript
|
set URL_user_entered to run_Utilities_handlers's replace_chars(URL_user_entered, "https://www.sbs.com.au/ondemand/watch/", "https://www.sbs.com.au/api/v3/video_smil?id=")
|
Main.applescript
|
set YTDL_log_file to MacYTDL_preferences_path & "youtube-dl_log-" & SBS_show_name & "-" & download_date_time & ".txt"
|
Main.applescript
|
set YTDL_output_template to "-o '" & SBS_show_name & "-%(autonumber)s.%(ext)s'"
|
Main.applescript
|
set download_filename_new to run_Utilities_handlers's replace_chars(SBS_show_name, " ", "_")
|
Main.applescript
|
set download_filename to SBS_show_name
|
Main.applescript
|
set SBS_show_name_underscore to run_Utilities_handlers's replace_chars(SBS_show_name, " ", "_")
|
Main.applescript
|
set YTDL_log_file to MacYTDL_preferences_path & "youtube-dl_log-" & SBS_show_name_underscore & "-" & download_date_time & ".txt"
|
Main.applescript
|
set download_filename_new to run_Utilities_handlers's replace_chars(download_filename_new, ":", "_-")
|
Main.applescript
|
return URL_user_entered
|
Main.applescript
|
end set_File_Names
|
Main.applescript
|
on check_subtitles_download_available(shellPath, diag_Title, subtitles_choice, URL_user_entered, theButtonQuitLabel, theButtonReturnLabel, theButtonContinueLabel, MacYTDL_custom_icon_file, DL_Use_YTDLP)
|
Main.applescript
|
set author_gen to subtitles_choice
|
Main.applescript
|
set auto_gen to DL_YTAutoST
|
Main.applescript
|
if ABC_show_name is "" and SBS_show_name is "" then
|
Main.applescript
|
set URL_for_subtitles_test to URL_user_entered_clean
|
Main.applescript
|
set URL_for_subtitles_test to URL_user_entered
|
Main.applescript
|
if auto_gen is true and author_gen is false and URL_for_subtitles_test does not contain "YouTube" and URL_for_subtitles_test does not contain "YouTu.be" then
|
Main.applescript
|
set theAutoSTWillNotWorkLabel to localized string "You have specified auto-generated subtitles but not from Youtube. It will not work. Do you want to try author generated subtitles, continue without subtitles or cancel this download and return to the Main dialog ?" from table "MacYTDL"
|
Main.applescript
|
set theButtonContinueGoAuthorLabel to localized string "Try author" from table "MacYTDL"
|
Main.applescript
|
set auto_subtitles_stop_or_continue to button returned of (display dialog theAutoSTWillNotWorkLabel buttons {theButtonContinueGoAuthorLabel, theButtonContinueLabel, theButtonReturnLabel} default button 1 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600)
|
Main.applescript
|
if auto_subtitles_stop_or_continue is theButtonReturnLabel then
|
Main.applescript
|
else if auto_subtitles_stop_or_continue is theButtonContinueGoAuthorLabel then
|
Main.applescript
|
set author_gen to true
|
Main.applescript
|
set auto_gen to false
|
Main.applescript
|
else if auto_subtitles_stop_or_continue is theButtonContinueLabel then
|
Main.applescript
|
return YTDL_subtitles
|
Main.applescript
|
set check_subtitles_available to do shell script shellPath & DL_Use_YTDLP & " --list-subs --ignore-errors " & URL_for_subtitles_test
|
Main.applescript
|
if check_subtitles_available does not contain "Language formats" and check_subtitles_available does not contain "Language formats" and check_subtitles_available does not contain "Language Name" then
|
Main.applescript
|
set theSTNotAvailableLabel1 to localized string "There is no subtitle file available for your video (although it might be embedded)." from table "MacYTDL"
|
Main.applescript
|
set theSTNotAvailableLabel2 to localized string "You can quit, stop and return or download anyway." from table "MacYTDL"
|
Main.applescript
|
set subtitles_quit_or_continue to button returned of (display dialog theSTNotAvailableLabel1 & return & return & theSTNotAvailableLabel2 buttons {theButtonQuitLabel, theButtonReturnLabel, theButtonContinueLabel} default button 3 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600)
|
Main.applescript
|
if subtitles_quit_or_continue is theButtonQuitLabel then
|
Main.applescript
|
else if subtitles_quit_or_continue is theButtonReturnLabel then
|
Main.applescript
|
else if check_subtitles_available contains "Language formats" or check_subtitles_available contains "Language formats" or check_subtitles_available contains "Language Name" then
|
Main.applescript
|
if auto_gen is true and author_gen is false and check_subtitles_available does not contain "Available automatic captions for" and check_subtitles_available contains "Available subtitles for" then
|
Main.applescript
|
set theNoAutoYesAuthorLabel to localized string "You have specified auto-generated subtitles but only author generated are available. Do you want author generated subtitles, continue without subtitles or cancel this download and return to the Main dialog ?" from table "MacYTDL"
|
Main.applescript
|
set theButtonContinueGoAuthorLabel to localized string "Get author" from table "MacYTDL"
|
Main.applescript
|
else if auto_gen is false and author_gen is true and check_subtitles_available contains "Available automatic captions for" and check_subtitles_available does not contain "Available subtitles for" then
|
Main.applescript
|
set theNoAutoYesAuthorLabel to localized string "You have specified author-generated subtitles but only auto-generated are available. Do you want auto-generated subtitles, continue without subtitles or cancel this download and return to the Main dialog ?" from table "MacYTDL"
|
Main.applescript
|
set theButtonContinueGoAutoLabel to localized string "Get auto" from table "MacYTDL"
|
Main.applescript
|
set auto_subtitles_stop_or_continue to button returned of (display dialog theNoAutoYesAuthorLabel buttons {theButtonContinueGoAutoLabel, theButtonContinueLabel, theButtonReturnLabel} default button 1 with title diag_Title with icon file MacYTDL_custom_icon_file giving up after 600)
|
Main.applescript
|
else if auto_subtitles_stop_or_continue is theButtonContinueGoAutoLabel then
|
Main.applescript
|
set author_gen to false
|
Main.applescript
|
set auto_gen to true
|
Main.applescript
|
set subtitles_info to ""
|
Main.applescript
|
set log_ST_paragraphs to paragraphs of check_subtitles_available
|
Main.applescript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.