Skip to content

Instantly share code, notes, and snippets.

@megabitsenmzq
Created July 13, 2020 14:35
Show Gist options
  • Save megabitsenmzq/ab97c9247493629b32d484325dd3d547 to your computer and use it in GitHub Desktop.
Save megabitsenmzq/ab97c9247493629b32d484325dd3d547 to your computer and use it in GitHub Desktop.
iTunes Store metadata plugin for mp3tag (JP store as default).
########################################################
# iTunes API Sources Script for Mp3Tag #
# #
#version 1.1 #
#created by Megabits in 2019 #
########################################################
########################################################
# SEARCH BY DIALOG #
########################################################
[Name]=iTunes
[BasedOn]=http://itunes.apple.com
#US [IndexUrl]=http://itunes.apple.com/search?term=%s&entity=album&limit=100
[IndexUrl]=http://itunes.apple.com/search?term=%s&entity=album&limit=100&lang=ja_jp&country=JP
[AlbumUrl]=http://itunes.apple.com/lookup?id=
[WordSeperator]=+
[IndexFormat]=%_preview%|%_url%|%Artist%|%Album%|%Tracks%|%Type%|%Copyright%|
[SearchBy]=%artist% %album%
[Encoding]=url-utf-8
########################################################
# LIST OF SEARCH RESULTS DIALOG #
########################################################
[ParserScriptIndex]=...
findline "wrapperType\""
do
joinuntil "}"
replace "\\\"" "\""
replace "?uo=4" ""
# PREVIEW
sayregexp "(?<=\"collectionViewUrl\":\").+?(?=\")" ", " "}"
say "|"
# URL
sayregexp "(?<=\"collectionId\":)\d+?(?=,)" ", " "}"
say "&entity=song&limit=200&country=JP"
say "|"
# ARTIST
sayregexp "(?<=\"artistName\":\")[^\"]{1,75}(?=.)" ", " "}"
say "|"
# ALBUM
sayregexp "(?<=\"collectionName\":\").+?(?=\")" ", " "}"
say "|"
# TRACKS
sayregexp "(?<=\"trackCount\":)\d+?(?=,)" ", " "}"
say "|"
# TYPE
sayregexp "(?<=\"collectionType\":\").+?(?=\")" ", " "}"
say "|"
# COPYRIGHT
sayregexp "(?<=\"copyright\":\").+?(?=\")" ", " "}"
say "|"
saynewline
findline "wrapperType\"" 2 1
while "{\"wrapperType" 201
########################################################
# ADJUST TAG INFORMATION DIALOG #
########################################################
[ParserScriptAlbum]=...
findline "wrapperType\""
joinuntil "}"
outputto "COVERURL"
replace "100x100" "1400x1400"
sayregexp "(?<=\"artworkUrl100\":\").+?(?=\")" ", " "}"
outputto "ALBUMARTIST"
sayregexp "(?<=\"artistName\":\").+?(?=\")" ", " "}"
outputto "YEAR"
sayregexp "(?<=\"copyright\":\")\d\d\d\d(?=.)" ", " "}"
regexpreplace "(\d\d\d\d),?" "<<<year$1>>>"
findinline "\"copyright\":\"" 1 1
ifnot "<<<year"
gotochar 1
sayregexp "(?<=\"releaseDate\":\"<<<year)\d\d\d\d(?=>>>)" ", " "}"
else
gotochar 1
endif
outputto "PUBLISHER"
regexpreplace "<<<year\d*>>>" ""
regexpreplace " +" " "
sayregexp "(?<=\"copyright\":\").+?(?=\")" ", " "}"
# GET TRANSLATED ALBUM NAME
findline "wrapperType\"" 2 1
joinuntil "}"
outputto "ALBUM"
sayregexp "(?<=\"collectionName\":\").+?(?=\")" ", " "}"
MoveLine -1
# TRACK LOOP
findline "wrapperType\"" 2 1
do
joinuntil "}"
replace "\\\"" "\""
outputto "TRACKS"
sayregexp "(?<=\"trackCensoredName\":\").+?(?=\")" ", " "}"
#sayregexp "(?<=\"trackName\":\").+?(?=\")" ", " "}"
say "|"
outputto "ARTIST"
sayregexp "(?<=\"artistName\":\").+?(?=\")" ", " "}"
say "|"
outputto "GENRE"
sayregexp "(?<=\"primaryGenreName\":\").+?(?=\")" ", " "}"
say "|"
outputto "_LENGTH"
sayregexp "(?<=\"trackTimeMillis\":)\d+?(?=\D)" ", " "}"
say "|"
findline "wrapperType\"" 2 1
while "{\"wrapperType"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment