Skip to content

Instantly share code, notes, and snippets.

View Pe8er's full-sized avatar
🤡
Calzone will not be tolerated

Piotr Gajos Pe8er

🤡
Calzone will not be tolerated
View GitHub Profile
@Pe8er
Pe8er / (0000) Album_00 Title.m4a.ptsp
Created April 30, 2025 19:23
My Picard File Rename Script
title: (0000) Album/00 Title.m4a
description: |
This preset example file naming script does not require any special settings, tagging scripts or plugins.
author: MusicBrainz Picard Development Team
license: GNU Public License version 2
version: '1.0'
last_updated: 2019-08-05 13:40:00 UTC
script_language_version: '1.0'
script: |
%albumartist%/\($if(%originalyear%,%originalyear%,$if(%date%,$left(%date%,4),0000))\) %album%/$if($gt(%totaldiscs%,1),%discnumber%-)$num(%tracknumber%,2) $if2(%albumartist%,%artist%) - %title%
{
"BTTWidgetName" : "Next Event",
"BTTTriggerType" : 639,
"BTTTriggerTypeDescription" : "Apple Script Widget",
"BTTTriggerClass" : "BTTTriggerTypeTouchBar",
"BTTPredefinedActionType" : 49,
"BTTPredefinedActionName" : "Launch Application \/ Open File \/ Start Apple Script …",
"BTTLaunchPath" : "file:\/\/\/Applications\/Calendar.app",
"BTTAdditionalConfiguration" : "\/bin\/bash:::-c",
"BTTEnabled2" : 0,
set nextEvent to do shell script "~/.dotfiles/bin/icalBuddy -ec 'Found in Natural Language' -npn -nc -iep 'datetime,title' -po 'datetime,title' -eed -ea -n -li 1 -ps '|: |' -b '' eventsToday"
--log nextEvent
if nextEvent is not "" then
set AppleScript's text item delimiters to " @& "
set itemCount to count of text items of nextEvent
--log itemCount
if itemCount is 1 then
{
"BTTPresetName" : "Default",
"BTTPresetUUID" : "77CE7DAA-5E4B-4BD5-AE1C-7165D3F519FF",
"BTTPresetContent" : [
{
"BTTAppBundleIdentifier" : "BT.G",
"BTTAppName" : "Global",
"BTTAppSpecificSettings" : {
},
on run arguments
-- Debugger
if class of arguments is script then set arguments to {"US/Pacific", "Pacifica", "24"}
tell arguments
-- Set up the location and city name
set theLocation to item 1
set APIKey to "????" -- your secret Dark Sky API key. Get it here: https://darksky.net/dev/account
tell application "JSON Helper"
try
set latLon to do shell script "/usr/local/bin/locateme -f '{LAT},{LON}'"
set weather to fetch JSON from "https://api.darksky.net/forecast/" & APIKey & "/" & latLon & "?exclude=minutely,hourly,daily,alerts,flags&units=si"
on error e
return e
end try
set nextEvent to do shell script "~/.dotfiles/bin/icalBuddy -ec 'Found in Natural Language' -npn -nc -iep 'title,datetime,location' -eed -ea -n -li 1 -ps '| @& |' -b '' eventsToday"
log nextEvent
if nextEvent is not "" then
set AppleScript's text item delimiters to " @& "
set itemCount to count of text items of nextEvent
--log itemCount
if itemCount is 1 then
set localComputer to "" -- enter name of a remote computer
set username to "" -- remote computer username
set computerPassword to "" -- remote computer password
set remoteComputer to "eppc://" & username & ":" & computerPassword & "@" & localComputer
set rTunes to application "iTunes" of machine remoteComputer
if application "iTunes" is running then
try
tell application "iTunes"
set {tArtist, tName, tAlbum, theID} to {artist, name, album, database ID} of current track
if application "iTunes" is running then
tell application "iTunes" to set {tArtist, tName, tAlbum, isLoved} to {artist, name, album, loved} of current track
if isLoved is true then
set isLoved to "★" & space
else
set isLoved to "☆" & space
end if
return isLoved & tArtist & space & "-" & space & tName
else
return ""
global jsonWeek, jsonYear, jsonAthlete, athleteID
property token : "????" -- your Strava API access token. Get it here: https://www.strava.com/settings/api
property yearRideGoal : 2000 -- in kilometers
property enableLogging : "off" --- options: on | off
on run theArgument
-- Set up the JSON files
tell application "Finder"