Skip to content

Commit

Permalink
add raycast script
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Jul 13, 2024
1 parent a9d24d4 commit 6718464
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions publisher/radio-t-process.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

# @raycast.schemaVersion 1
# @raycast.title radio-t process and publish mp3
# @raycast.mode silent
#
# Optional parameters:
# @raycast.icon 🎙
# @raycast.packageName Podcasts

cat <<'EOF' > /tmp/process_and_publish_mp3.sh
set -e
# Get the currently selected file in Finder
selectedFile=$(osascript -e 'tell application "Finder"' -e 'set selectedItems to selection' -e 'if (count of selectedItems) > 0 then' -e 'set selectedItem to item 1 of selectedItems' -e 'POSIX path of (selectedItem as alias)' -e 'else' -e '""' -e 'end if' -e 'end tell')
# Extract episode number from the full path
filename=$(basename "${selectedFile}")
episodeNumber=$(echo "${filename}" | sed -E 's/rt_podcast([0-9]+)\.mp3/\1/')
# Check if episode number is valid (purely numeric and not empty)
if ! [[ $episodeNumber =~ ^[0-9]+$ ]]; then
say -v Alex "processing failed, wrong file name"
echo "Error: Filename does not match expected pattern 'rt_podcastNNN.mp3'"
exit 1
fi
echo "selected file: ${selectedFile}, episode number: ${episodeNumber}"
say -v Alex "starting processing for episode $episodeNumber"
cd ~/dev.umputun/radio-t.com/radio-t-site/publisher
make proc-mp3 FILE=${selectedFile}
echo "done"
osascript -e "display notification \"processing completed for $episodeNumber\" with title \"RADIO-T\""
say "completed processing for episode $episodeNumber"
EOF

# Make the script executable
chmod +x /tmp/process_and_publish_mp3.sh

# Use AppleScript to open a new Terminal window and execute the script
osascript <<END
tell application "Terminal"
do script "/bin/sh /tmp/process_and_publish_mp3.sh"
activate
end tell
END

0 comments on commit 6718464

Please sign in to comment.