text
stringlengths
0
15.7k
source
stringlengths
6
112
set {batch_instruct, theTop} to create label instructions_text left inset 75 bottom (theTop + 30) max width minWidth - 75 aligns left aligned with multiline
Main.applescript
set {batch_prompt, theTop} to create label batch_diag_prompt left inset 0 bottom (theTop) max width minWidth aligns center aligned with bold type
Main.applescript
set batch_allControls to {theBatchRule, batch_tally, MacYTDL_icon, batch_instruct, batch_prompt}
Main.applescript
set {batch_button_returned, batchButtonNumberReturned, batch_controls_results} to display enhanced window diag_Title buttons theButtons acc view width minWidth acc view height theTop acc view controls batch_allControls initial position window_Position
Main.applescript
if batchButtonNumberReturned is 5 then
Main.applescript
download_batch(folder_chosen, remux_format_choice, subtitles_choice, YTDL_credentials, YTDL_subtitles, YTDL_STEmbed, YTDL_format, YTDL_remux_format, YTDL_Remux_original, YTDL_description, YTDL_audio_only, YTDL_audio_codec, YTDL_over_writes, YTDL_Thumbnail_Write, YTDL_Thumbnail_Embed, YTDL_metadata, YTDL_limit_rate_value, YTDL_verbose, YTDL_TimeStamps, YTDL_Use_Proxy, YTDL_Use_Cookies, YTDL_Custom_Settings, YTDL_Custom_Template, YTDL_no_part, YTDL_QT_Compat, DL_Use_YTDLP)
Main.applescript
else if batchButtonNumberReturned is 2 then
Main.applescript
set batch_file_test to batch_file as string
Main.applescript
if not (exists file batch_file_test) then
Main.applescript
set theNoBatchFileLabel to localized string "Sorry, there is no batch file." from table "MacYTDL"
Main.applescript
display dialog theNoBatchFileLabel with title diag_Title buttons {theButtonOKLabel} default button 1 with icon file MacYTDL_custom_icon_file giving up after 600
Main.applescript
set batch_file_posix to POSIX path of batch_file
Main.applescript
tell application "System Events" to open file batch_file_posix
Main.applescript
open_batch_processing(folder_chosen, remux_format_choice, subtitles_choice, YTDL_credentials, YTDL_subtitles, YTDL_STEmbed, YTDL_format, YTDL_remux_format, YTDL_Remux_original, YTDL_description, YTDL_audio_only, YTDL_audio_codec, YTDL_over_writes, YTDL_Thumbnail_Write, YTDL_Thumbnail_Embed, YTDL_metadata, YTDL_limit_rate_value, YTDL_verbose, YTDL_TimeStamps, YTDL_Use_Proxy, YTDL_Use_Cookies, YTDL_Custom_Settings, YTDL_Custom_Template, YTDL_no_part, YTDL_QT_Compat)
Main.applescript
else if (batchButtonNumberReturned is 3) or ((batchButtonNumberReturned is 4) and (batch_tally_number is 1)) then
Main.applescript
clear_batch(folder_chosen, remux_format_choice, subtitles_choice, YTDL_credentials, YTDL_subtitles, YTDL_STEmbed, YTDL_format, YTDL_remux_format, YTDL_Remux_original, YTDL_description, YTDL_audio_only, YTDL_audio_codec, YTDL_over_writes, YTDL_Thumbnail_Write, YTDL_Thumbnail_Embed, YTDL_metadata, YTDL_limit_rate_value, YTDL_verbose, YTDL_TimeStamps, YTDL_Use_Proxy, YTDL_Use_Cookies, YTDL_Custom_Settings, YTDL_Custom_Template, YTDL_no_part, YTDL_QT_Compat)
Main.applescript
else if batchButtonNumberReturned is 4 then
Main.applescript
remove_last_from_batch(folder_chosen, remux_format_choice, subtitles_choice, YTDL_credentials, YTDL_subtitles, YTDL_STEmbed, YTDL_format, YTDL_remux_format, YTDL_Remux_original, YTDL_description, YTDL_audio_only, YTDL_audio_codec, YTDL_over_writes, YTDL_Thumbnail_Write, YTDL_Thumbnail_Embed, YTDL_metadata, YTDL_limit_rate_value, YTDL_verbose, YTDL_TimeStamps, YTDL_Use_Proxy, YTDL_Use_Cookies, YTDL_Custom_Settings, YTDL_Custom_Template, YTDL_no_part, YTDL_QT_Compat)
Main.applescript
end open_batch_processing
Main.applescript
on tally_batch()
Main.applescript
set number_of_URLs to 0
Main.applescript
return number_of_URLs
Main.applescript
if (get eof file batch_file) is 0 then
Main.applescript
set batch_file_ref to missing value
Main.applescript
set batch_file_ref to open for access file batch_file
Main.applescript
set batch_URLs to read batch_file_ref from 1 as «class utf8»
Main.applescript
set number_of_URLs to (count of paragraphs in batch_URLs) - 1
Main.applescript
close access batch_file_ref
Main.applescript
display dialog theBatchErrorLabel & batch_errMsg & "batch_file: " & batch_file with title "Tally_batch handler" buttons {theButtonOKLabel} default button 1
Main.applescript
end tally_batch
Main.applescript
on download_batch(folder_chosen, remux_format_choice, subtitles_choice, YTDL_credentials, YTDL_subtitles, YTDL_STEmbed, YTDL_format, YTDL_remux_format, YTDL_Remux_original, YTDL_description, YTDL_audio_only, YTDL_audio_codec, YTDL_over_writes, YTDL_Thumbnail_Write, YTDL_Thumbnail_Embed, YTDL_metadata, YTDL_limit_rate_value, YTDL_verbose, YTDL_TimeStamps, YTDL_Use_Proxy, YTDL_Use_Cookies, YTDL_Custom_Settings, YTDL_Custom_Template, YTDL_no_part, YTDL_QT_Compat, DL_Use_YTDLP)
Main.applescript
set no_batch_file to false
Main.applescript
if not (exists file batch_file_test) then set no_batch_file to true
Main.applescript
if no_batch_file is true then
Main.applescript
my open_batch_processing(folder_chosen, remux_format_choice, subtitles_choice, YTDL_credentials, YTDL_subtitles, YTDL_STEmbed, YTDL_format, YTDL_remux_format, YTDL_Remux_original, YTDL_description, YTDL_audio_only, YTDL_audio_codec, YTDL_over_writes, YTDL_Thumbnail_Write, YTDL_Thumbnail_Embed, YTDL_metadata, YTDL_limit_rate_value, YTDL_verbose, YTDL_TimeStamps, YTDL_Use_Proxy, YTDL_Use_Cookies, YTDL_Custom_Settings, YTDL_Custom_Template, YTDL_no_part, YTDL_QT_Compat)
Main.applescript
set theEmptyBatchFileLabel to localized string "Sorry, the batch file is empty." from table "MacYTDL"
Main.applescript
display dialog theEmptyBatchFileLabel with title diag_Title buttons {theButtonOKLabel} default button 1 with icon file MacYTDL_custom_icon_file giving up after 600
Main.applescript
set YTDL_log_file to MacYTDL_preferences_path & "youtube-dl_log-Batch_download_on-" & download_date_time & ".txt"
Main.applescript
set batch_file_contents to read batch_file_ref as «class utf8»
Main.applescript
set bad_Batch_file_edits to "No"
Main.applescript
set AppleScript's text item delimiters to {"#", "$", return}
Main.applescript
repeat with aPara in (paragraphs of batch_file_contents)
Main.applescript
if length of aPara is greater than 2 then
Main.applescript
if aPara does not contain "#" then
Main.applescript
set bad_Batch_file_edits to "Yes"
Main.applescript
set num_sections to number of text items in aPara
Main.applescript
if num_sections is not equal to 3 then
Main.applescript
if bad_Batch_file_edits is "Yes" then
Main.applescript
set theBadBatchFileEditsLabel to localized string "Sorry, it seems the batch file has been edited with the wrong format. Check the Help manual for advice on how to edit the batch file." from table "MacYTDL"
Main.applescript
display dialog theBadBatchFileEditsLabel with title diag_Title buttons {theButtonOKLabel} default button 1 with icon file MacYTDL_custom_icon_file giving up after 600
Main.applescript
set download_filename to text item 2 of batch_file_contents
Main.applescript
set YTDL_remux_format to text item 3 of batch_file_contents
Main.applescript
set download_filename to text 1 thru -1 of download_filename -- Probably not needed but, is a safety measure
Main.applescript
if length of YTDL_remux_format is greater than 5 then
Main.applescript
set YTDL_remux_format to text 1 thru -2 of YTDL_remux_format
Main.applescript
set download_filename_new to "the saved batch"
Main.applescript
set download_filename to run_Utilities_handlers's replace_chars(download_filename, "_", " ")
Main.applescript
set YTDL_batch_file to quoted form of POSIX path of batch_file
Main.applescript
set YTDL_simulate_log to "Null"
Main.applescript
set URL_user_entered to "Null"
Main.applescript
set ytdl_settings to quoted form of (" --ignore-errors --newline " & YTDL_subtitles & YTDL_STEmbed & YTDL_credentials & YTDL_format & YTDL_remux_format & " " & YTDL_Remux_original & YTDL_description & YTDL_audio_only & YTDL_audio_codec & YTDL_over_writes & YTDL_Thumbnail_Write & YTDL_Thumbnail_Embed & YTDL_metadata & YTDL_limit_rate_value & YTDL_verbose & YTDL_Use_Proxy & YTDL_Use_Cookies & YTDL_no_part & YTDL_Custom_Settings & YTDL_output_template & " " & YTDL_QT_Compat & " --batch-file " & YTDL_batch_file)
Main.applescript
set my_params to quoted form of folder_chosen & " " & quoted form of MacYTDL_preferences_path & " " & YTDL_TimeStamps_quoted & " " & ytdl_settings & " " & URL_user_entered & " " & YTDL_log_file & " " & download_filename & " " & download_filename_new & " " & quoted form of MacYTDL_custom_icon_file_posix & " " & monitor_dialog_position & " " & YTDL_simulate_log & " " & diag_Title_quoted & " " & is_Livestream_Flag & " " & screen_width & " " & screen_height & " " & DL_Use_YTDLP & " " & quoted form of path_to_MacYTDL
Main.applescript
end download_batch
Main.applescript
on clear_batch(folder_chosen, remux_format_choice, subtitles_choice, YTDL_credentials, YTDL_subtitles, YTDL_STEmbed, YTDL_format, YTDL_remux_format, YTDL_Remux_original, YTDL_description, YTDL_audio_only, YTDL_audio_codec, YTDL_over_writes, YTDL_Thumbnail_Write, YTDL_Thumbnail_Embed, YTDL_metadata, YTDL_limit_rate_value, YTDL_verbose, YTDL_TimeStamps, YTDL_Use_Proxy, YTDL_Use_Cookies, YTDL_Custom_Template, YTDL_Custom_Settings, YTDL_no_part, YTDL_QT_Compat)
Main.applescript
open_batch_processing(folder_chosen, remux_format_choice, subtitles_choice, YTDL_credentials, YTDL_subtitles, YTDL_STEmbed, YTDL_format, YTDL_remux_format, YTDL_Remux_original, YTDL_description, YTDL_audio_only, YTDL_audio_codec, YTDL_over_writes, YTDL_Thumbnail_Write, YTDL_Thumbnail_Embed, YTDL_metadata, YTDL_limit_rate_value, YTDL_verbose, YTDL_TimeStamps, YTDL_Use_Proxy, YTDL_Use_Cookies, YTDL_Custom_Template, YTDL_Custom_Settings, YTDL_no_part, YTDL_QT_Compat)
Main.applescript
set batch_file_ref to open for access file batch_file with write permission
Main.applescript
set eof batch_file_ref to 0
Main.applescript
display dialog theBatchErrorLabel & batch_errMsg & "batch_file: " & batch_file buttons {theButtonOKLabel} default button 1
Main.applescript
end clear_batch
Main.applescript
on remove_last_from_batch(folder_chosen, remux_format_choice, subtitles_choice, YTDL_credentials, YTDL_subtitles, YTDL_STEmbed, YTDL_format, YTDL_remux_format, YTDL_Remux_original, YTDL_description, YTDL_audio_only, YTDL_audio_codec, YTDL_over_writes, YTDL_Thumbnail_Write, YTDL_Thumbnail_Embed, YTDL_metadata, YTDL_limit_rate_value, YTDL_verbose, YTDL_TimeStamps, YTDL_Use_Proxy, YTDL_Use_Cookies, YTDL_Custom_Template, YTDL_Custom_Settings, YTDL_no_part, YTDL_QT_Compat)
Main.applescript
set batch_URLs to text 1 thru -4 of batch_URLs --<= remove last few characters to remove last return
Main.applescript
set last_URL_offset to last item of allOffset(batch_URLs, return) --<= Get last in list of offsets of returns
Main.applescript
set new_batch_contents to text 1 thru (last_URL_offset - 1) of batch_URLs --<= Trim off last URL
Main.applescript
set eof batch_file_ref to 0 --<= Empty the batch file
Main.applescript
write new_batch_contents & return to batch_file_ref as «class utf8» --<= Write out all URLs except the last
Main.applescript
on error batch_errMsg number errorNumber
Main.applescript
set theBatchErrorLabel to localized string "There was an error: number " from table "MacYTDL"
Main.applescript
display dialog theBatchErrorLabel & errorNumber & " - " & batch_errMsg & " batch_file: " & batch_file buttons {theButtonOKLabel} default button 1
Main.applescript
end remove_last_from_batch
Main.applescript
on get_screensize()
Main.applescript
script theScript
Main.applescript
property parent : a reference to current application
Main.applescript
set mainScreenFrame to current application's NSScreen's mainScreen()'s frame()
Main.applescript
set screen_width to current application's NSWidth(mainScreenFrame)
Main.applescript
set screen_height to current application's NSHeight(mainScreenFrame)
Main.applescript
set X_position to (screen_width / 10)
Main.applescript
on error errText
Main.applescript
display dialog "There was an error: " & errText
Main.applescript
set X_position to 50
Main.applescript
set Y_position to 50
Main.applescript
return X_position & Y_position & screen_width & screen_height
Main.applescript
end get_screensize
Main.applescript
return theScript's get_screensize()
Main.applescript
on allOffset(theString, thechar)
Main.applescript
set theString to theString as text
Main.applescript
set reverse_offsetList to {}
Main.applescript
repeat with i from 1 to length of theString
Main.applescript
if item i of theString is thechar then
Main.applescript
set end of reverse_offsetList to i
Main.applescript
return reverse_offsetList
Main.applescript