[WS] iTunes source script with multiple search criteria

Hello Shocking,

I don't have access to a Mac installation, so I cannot guarantee, but from my knowledge, the web source framework (upon which all scripts function) is the same in both Mac and Windows versions of Mp3Tag. I haven't/can't test my script in an Mac installation.

And since @Florian is already on the case, I'll defer to his findings.

A few questions though:

this means that you can perform a query, and get query results, yes?
And only when you click on an album 'result' does the script crash - correct?
Does this crash happen immediately when you click on the album, or is more the case that the script/Mp3Tag stops responding and/or eventually leading to a crash after a period of time?
Does this happen on a specific album, or with any album from the query?
On the settings' schema, do you use a custom size, or one of the presets?

The current version of the script (3.50) has 5 scripts in the .zip package (plus settings' file); on the query input stage each script - for convenience - is pre-filled (or not) with localization data (country code + language code); however you can change that pre-filled data to the values you want. This means that all 5 scripts can be made to perform the same search, if provided with the same criteria. If provided the same query criteria, does this crash happen in all 5 scripts?

I've already found the cause of the crash today and submitted a new version to Apple for review. It's related to using a negative value for maximum number of items to select at json_select_many.

The next version will handle this case correctly (select all available items), so no need to change anything or to investigate further.

1 Like

@Shocking You can ignore these questions, as @Florian has already cracked the case.

I will update the sticky with a warning regarding the Mac version until a fix is available.

2 Likes

I've just released Mp3tag for Mac 1.8.14 which should fix the issue you were observing. Thanks again for reporting!

2 Likes

No problem at all. Glad to help. And thank you ever so much for the speedy fix. I shall look forward to test-driving it over the weekend. :slightly_smiling_face:

2 Likes

Hello,

I'm the newnew and this is my first post (just signed up for this). I love mp3tag and using it for years but it's the first time for me beeing registred in the forum. Keep up the good work.

What I wanted to ask is if it is possible to use the iTunes source to get "Cover Art Only" (without any other tags)? If yes, how?
I do not want to deselect a lot of tags just to get the cover art only. Sometimes the tags in my collection are fully okay and only the cover needs to be adjusted (e.g. smaller size or better resolution of my old files).
Since "Amazon" is out of the "Cover Art"-Branch (yeah I'm that old), only Discogs and Musicbrainz are left. It would be very nice if iTunes (and/or Spotify/Deezer) could be added too. Maybe someone can rewrite it.

Thank you all again for this nice thing. Wish you a nice weekend.

Yes.
Just deselect all the tags you don't want - in your case ALL of them in the "Adjust tag information" window, appearing with your selected album:

This works for ALL WebSourceScripts. Your settings will be even remembered, so you have to deselect them only once.

Thanks for your response. Of course I know THAT way (like I mentioned but maybe it was not clear enough). What I was asking for a script that has this as "default setting" as an "extra/additional" script. Because switching between selected tags (select and unselect whenever I need cover art only, which is not that often) will get tedious (over time). So I need two separate scripts (well, one is already available so I need only one more). One that is availaible from here which works really nice since I am using it (so it's not needed anymore since it exists, thanks) AND/PLUS another one (maybe a rework/"cutted version" of this) for "get Cover Art only" (that will be in the "Cover Art"-Ribbon). Hope it is more clear now. Sorry english is not my native language.

Hello @newnew and welcome.

If I'm reading this correctly you want a version of this script with the text tags completely removed, and only showing the cover?

See if this works:

**EDIT: Removed attached file

I edited the original iTunes WS#350_[Any] - [Localized] script and removed everything but the cover tag. It will use the same settings file as version 3.50, so you will have to change cover art size via that options panel. It will also load artist and album in the query field as per the original script.

Please note I made this just now; it is a beta script, and as such did not test it thoroughly.

Give it a try - if it works well, I'll add it to the main post.

Thank you rboss for your help.

Unfortunately it says: "ERROR(Settings): expected value, got 'i' (105) See scripterror.log for details" (the log file does not contain any more info so I do not have added it here).

I do not know if I clarified what I really want so I try again:

I want a script that uses Apple/iTunes (or if someone can do it wihout api or login; Spotify/Deezer would be also nice) in cases where I need to get the cover art only. No deleting or replacing of existing tags or something (only a simple cover search/add/replace). So it could be integrated to the "Cover Art"-Ribbon as "Discogs" and "Musicbrainz" alternative (since Discogs need login and Musicbrainz do not find some albums/tracks from my collection but iTunes/Spotify/Deezer does).

So it could be something like "Cover Art#iTunes.src".

I am so sorry for my bad english. Hope someone will get it.

Are you using my other scripts as well? If so, add this script to the same folder as the others in your Mp3Tag installation.
If not, the 'iTunes WS#350#settings.settings' file is required in the same folder for the script to work (and to access all the features - including selecting cover size). You can find it in the first post.

Thank you, it works now (i figured it out in the meanwhile but thanks for writing it down additionally). I'm dumb (because I forgot that since version 3.50 settings-files are required). Sorry for bothering you which such things.

Could it be possible to make it as a "standalone" (without the need of other files/settings) also or does it necessarily need the dependencies? Would be more comfortable the way I proposed with "Cover Art#iTunes_rboss.src" where you only need one file. It could for exampel always choose "max. available resolution of api request" because resizing is easily possible via mp3tag batch scripts (afterwards).

A script that only displays the cover tag, in the biggest available size provided by the source, without needing dependencies?

iTunes WS#351a_pic_[Any] - [Localized].src (4.2 KB)

This should work. And since it works independently from other files, you can rename it to whatever you would like, and it should still work.

1 Like

Thank you rboss for providing that script. It works like a charm. I've tested it even with renaming ("Cover Art#iTunes_WS_Any_Loc_rboss.src") and it still works. So many thanks. U (really) R (the) Boss :smiley:. Maybe this could be added as a MP3Tag-standard/alternative-cover art-plugin (besides Discogs and musicbrainz) so others would also profit from it (but that's only a suggestion to Florian). But since anyone can just download your script and add it by themself within seconds it is not necessarily needed to have it as "built-in".

Wish you all a nice and relaxed sunday. Thanks again for all of your work.

Other topic: If Florian reads this: It would be really nice if MP3Tag would have an indicator/field that shows if an cover art is in "progressive" or "baseline" so there won't be the need (at least for me) to use any other additional/external program anymore. I am very thankfull that in newer version cover art processing is made possible <3. I love MP3Tag, all people that are active in the forums providing help and of course all people that are/were involved in the code developement process.

1 Like

@newnew Please don't mix/merge multiple questions into one topic.

Just create a new topic for your last "other topic" section.
For example in this category:

@LyricsLover thanks for reminding me. I know that. I might be "newnew" in this forum but not "generally" in forums (or the internet :joy:). I also wanted to have things structured/clear/clean.

So here is the separate thread: Feature Request: Adding Cover Art "Progressive/Baseline" column

Hello once again,

I am happy to release version 3.60 of my iTunes script with multiple search criteria.
Here's what's new:


Changes from v3.50:

  • ADDED: Overhaul of cover art support; now with settings available for image size, format, and quality
    I've built upon my previous version of this feature, and after learning that 'format' and 'quality' could also be changed in a cover art image link, added those options to the existing 'size' setting.

  • ADDED: Support for query thumbnails
    Starting with Mp3Tag v3.26, it is possible to have previews of album's cover art in the query results page. I included support for this feature in this version; additionally with control over preview quality or removal from results via a dedicated Settings command.

  • CHANGED: Redesigned Settings menu
    I tried -with the current design- to take a 'less is more approach': the elements in the Settings' menu were chosen and arranged to be read in a glance, with easily identifiable options, and fully interactive with just the mouse.
    However, I've also (experimentally) tried to have some of the current settings be displayed in the results window.
    So, when looking at the results of an album search, you can also have tags that output current settings.

  • CHANGED: Tag fields remapped/changed for better compatibility with iTunes
    This was a error caused by my lack of knowledge about tag field mappings. The tagging format and structure now in use (except custom ones, which are identified as such) should comply with the MP4 format (iTunes).

  • ADDED: Support for Apple Music
    "But this is an iTunes script! How dare you?!"
    Yes, and it still is -at its core. Originally I was working on 2 separate scripts, one for iTunes API, and one for Apple Music webpages, but I've hit a particularly tall hurdle that I'm not sure I can overcome in the Apple Music script's [ParserIndex] section. Meanwhile, i realized that I could have a [ParserIndex] section for iTunes API AND tweak those results for use in a [ParserAlbum] section using an Apple Music URL. Not long after that came the idea to have code for 2 sources in the same [ParserAlbum] section, with a setting to toggle between them.
    In short, there is now an "iTunes API" mode (initial query via iTunes API + album results via iTunes API) and a "Apple Music Web" mode (initial query via iTunes API + album results via Apple Music), so in regards to the workflow, this script is still (in its majority) an iTunes script.
    Oh, and the idea for cover image format support came from studying Apple Music pages' source code. Working for both sources in the same script has meant one was able to help improve the other, and vice-versa).
    However, Mp3Tag is not designed to support multiple sources in the same script (nor do I expect it to ever be); so I'm considering this feature as an a learning experiment.

  • REMOVED: Localized versions discontinued in favor of a single main release
    The main selling point of the localized versions was to have a pre-filled "Search by" window. But since both the query string and country string boxes would be almost always be changed, and the only change for the language string box is to keep "en-us" or "empty", which can be done with a couple of keystrokes, I decided not to release localized copies of my script and focus my energy on making a good script.

  • CHANGED: Optimized code
    I've also managed to shave off a few steps here and there in the code, to make the tagging process more efficient, even with the added features. 'iTunes API' mode should run as fast as before; 'Apple Music Web' will always be comparatively slower, since it first needs to process an entire album webpage to get the relevant pieces of data. But I did try to make it as efficient as I was able.

Here are the script and settings' files for version 3.60. The script is pre-filled for country= United States [US] and language= English [en-us], so change these values according to your needs. Use the link below or in the sticky (first post).

iTunes WS#360.zip (4.9 KB)

And enjoy.

2 Likes

Now then, here is an overview of the currently available settings, as well as some comments on their purpose and how to use them:
(choices marked with "**" are the default ones for that setting)


  • "Interface" group

The settings in this group are meant to customize what is shown during a search. Tags generated by options in this group refer to outputs of current settings and are not meant to be written into music files.

# Query thumbnails (drop-box)

  • tool-tip: "Display cover preview thumbnails in query results in selected size. Large sizes may impact performance"
  • choices: [|Small (100x100px)**|Medium (250x250px)|Large (600x600px)]
  • additional info: Please note that the actual size of the thumbnail shown when hovering with the cursor is fixed; a higher resolution will result in a higher quality image, but in a query that returns many results the system load to show large-sized images can slow the search (or even return an error). 100x100px is the fastest option for showing thumbnails; 600x600px should only be used in queries with few hits, and if the details of the cover require high-quality previews.

# Tag data source (drop-box)

  • tool-tip: "Retrieve tag data from iTunes API or Apple Music webpage. Query results provided by iTunes API"
  • choices: [Apple Music Web|iTunes API**]
  • additional info: Despite being both owned by Apple, both iTunes and Apple Music (AM) have differences in the amount (and quality) of information provided for music collections. I recommend trying both and see which better suits your tagging needs. As a rule of thumb, iTunes API will return results faster, but has less tag fields available; Apple Music Web parses an entire album webpage to get the necessary info, so it will be slower (but will provide more info). I'll be posting a side-by-side comparison of fields from both sources, showcasing their similarities (and differences).

# Show "#_SOURCE" tag (checkbox)

  • tool-tip: "Display current source as a custom tag in "Metadata Album"
  • choices: [enabled|disabled**]
  • additional info: During development, sometimes I would be looking at search results and not remembering if I was in "iTunes API" mode or "Apple Music Web" mode. There are signs (number of tags returned, format of data returned, etc.) that can be used to tell the difference, but there isn't a field that states that setting clearly in the results (which makes sense, because this dual source script is an experiment, and Mp3Tag was never meant to support it). Checking this box will show a "#_SOURCE" tag in the results window (under "Metadata Album"), indicating what database was used in the search. This tag is NOT meant to be written in music files; if your tagging needs put you going back and forth between sources, I recommend checking this option BUT uncheck the "#_SOURCE" tag in the results, as to not write its value to your files (selections are memorized).

# Show "#_COVERURL" tag (checkbox)

  • tool-tip: "Display cover URL as a custom tag in "Metadata Album"
  • choices: [enabled|disabled**]
  • additional info: For the overhaul of cover art settings, I asked the Mp3Tag community for help, and among the many useful suggestions, I noticed that many users already have their own method for adding cover art to their collection, and have the need to access the cover art image file outside of Mp3Tag's workspace. This option, when enabled, will show the URL of the image file displayed in the results' window. Additionally, the settings in the "Cover" group are reflected in the "#_COVERURL" tag, so the URL will also show the currently defined cover size, quality and format. This tag is NOT meant to be written in music files, so if you plan to use it, remember to keep it unchecked in the results window.

  • "Cover" group

The settings in this group apply customized preferences to the cover art shown in the results' page, which can be written into music files. These settings are output in the "#_COVERURL" tag.

# Use unmodified cover image (checkbox)

  • tool-tip: "Request cover in original dimensions/quality/format from source. Ignores other cover options"
  • choices: [enabled|disabled**]
  • additional info: Both sources use the same database for cover art, and using arguments in the request URL, you can modify the resulting image. As the title says, checking this box will modify the request URL to get the unmodified version of the cover art image. If you want the best available image from the source, this is the only option you need to check (as it supersedes all others), but results will be varied. If you want consistent cover parameters across your collection, keep this unchecked and use the other options in the "Cover" group.

# Size (drop-box)

  • tool-tip: "Set cover dimensions. Source is responsible for size results; large sizes may impact performance"
  • choices: [Small (100x100px)|Medium (600x600px)**|Large (1200x1200px)|Very large (2000x2000px)|<user-defined>]
  • additional info: These are commonly used sizes, so using a preset will usually return results compatible with most players; however if you have a need for a size outside of those listed, set this option to "<user-defined>" and use the following size options to set the desired value. Please note that the resulting cover size will always be a reduced version the maximum size of the original cover in the database and will conform to its aspect ratio. As an example, if the original cover is 800x1000px, choosing the 2000x2000px preset will return the 800x1000px cover; and choosing 600x600px will return a proportionally correct 480x600px image.

# Size > [user-defined] > (NNNN)
The following applies when 'Size' has been set to '<user-defined>'

# 1st digit of number (N---) (drop-box)
# 2nd digit of number (-N--) (drop-box)
# 3rd digit of number (--N-) (drop-box)
# 4th digit of number (---N) (drop-box)

  • tool-tip: "Use selection boxes to set each digit of user-defined cover size (e.g. 160x160px => 0-1-6-0)"
  • choices: [0-9] **preset to 1-2-3-0
  • additional info: As the tool-tip implies, a 4-digit cover size can be manually input using each drop-box per digit; for values below '1000', leading zeros must be used. Due to the nature of how settings' values are called from the script, the best solution I could find for a size input field was splitting a number into its component digits, setting each one individually (using drop-boxes allowed a mouse-only interface), and building the final value in the script. As a side note, a 0000x0000px size cover is possible, and will be returned as such. As with the presets, the resulting cover size will conform with the maximum size and aspect ratio of the source image.

# Format (drop-box)

  • tool-tip: "Select image format to be used. Some formats may impact performance"
  • choices: [.jpg**|.png|.webp]
  • additional info: "jpg" is considered a standard image format, as it provides a reasonably good image quality relative to its file size, and provides the most compatibility with players. "png" is a lossless compression format usually for high quality images, but may compromise compatibility. "webp" is a modern image format most commonly used for images on the web due to its smaller file size, and where quality isn't very important. There is no "one" format above all; you'll find many topics on this subject in the Mp3Tag community (and others). If you are unsure, the default should be fine.

# Quality (drop-box)

  • tool-tip: "Set image quality (on supported formats). Source is responsible for quality results"
  • choices: [< default >**|20%|40%|60%|80%|100%]
  • additional info: For greater control over cover image quality (useful in large collections where file size management is important), these presets -and the following quality options- allow to fine tune the resulting cover image. Please note that quality settings only take effect on image formats that support it (on "png" format the current quality setting will be shown in "#_COVERURL", but the image's original data -and size- will remain unaltered).
    As with Format, the default setting should suffice for most use cases.

# Quality > [user-defined] > (NN)
The following applies when 'Quality' has been set to '<user-defined>'

# 1st digit of number (N-) (drop-box)
# 2nd digit of number (-N) (drop-box)

  • tool-tip: "Use selection boxes to set each digit of user-defined quality value (e.g. 7% => 0-7)"
  • choices: [0-9] **preset to 5-0
  • additional info: similarly to Size, a 0-99 value for quality can be set using each respective drop-box per digit ("100" is available via preset), with a leading "0" for numbers below 10. "0" can be set, and results will vary: "png" will remain unchanged (as previously mentioned), "jpg" normally returns an image equivalent to 80% quality, and for "webp" format the cover quality apparently equals 60%. If such level of control is unnecessary, you may leave this option in its default.

  • "Track" group

Track settings will modify text-based tags, normally written to music files, or generate new ones, according to the options set.

The following applies when 'Tag data source' has been set to its default value 'iTunes API'
# [iTunes API] > Show album/track titles (drop-box)

  • tool-tip: "(for iTunes API) Display explicit content uncensored or *'d out. Source is responsible for content results"
  • choices: [Censored|Uncensored**]
  • additional info: an iTunes API album search returns both censored and uncensored versions of their respective data in the results (normally Track titles and Album titles); and previous versions of this script already included this feature. If set to 'Censored', the script takes additional steps to verify if the censored data is complete, and will use the uncensored equivalent of any missing values to provide a complete set of results. As there is no way to validate if data content is correctly filtered, all results are presented 'as is' from the source.

# Enable TOTALCOLLECTIONTRACKS (checkbox)

  • tool-tip: "Add non-standard TOTALCOLLECTIONTRACKS tag to results"
  • choices: [enabled|disabled**]
  • additional info: Compilation collections or multiple-disc albums are commonplace; however when referring to the 'Total Tracks' value in such context, it may refer to the total number of tracks in a disc OR the sum of the total tracks of all discs (which -given the nature of current digital music services- may be more suitable than that of a physically limited 'disc'). iTunes API provides both values in its raw data; Apple Music only provides the number of total tracks in the collection, but its raw data has track information structured into groups corresponding to the equivalent physical discs, so the total tracks 'of disc' value(s) can be extrapolated from them. As most players normally only recognize one field to represent the total amount of tracks in a 'set' (regardless of the constitution of that set), I decided to have the TOTALTRACKS tag field (native to Apple) reflect the total tracks of Disc. The total number of tracks of the collection (of tracks) is produced in a custom TOTALCOLLECTIONTRACKS tag field which can be toggled using this checkbox. If you have no need for a TOTALCOLLECTIONTRACKS tag, simply keep this option unchecked; if you want both values of total tracks, TOTALTRACKS will always refer to 'Disc', and TOTALCOLLECTIONTRACKS will always refer to 'Collection'. In the need for TOTALTRACKS to refer to 'Collection', this can be achieved with further processing in Mp3Tag. As the TOTALCOLLECTIONTRACKS tag is of my design, compatibility with other players may not be possible without adjustments, if at all. Please consider your particular use case before enabling.

As a final note, please take into consideration that this script is developed and distributed as a hobby, and while I try to have it return correct data from its source(s), this may not always be the case, and therefore it should NOT be relied upon, nor should its use or results (intentional or otherwise) reflect those of the Mp3Tag software.

Overview of tag fields provided in WS script v3.60. Tags used internally by Mp3Tag are not included.
Custom tags unique to this script are indicated as such.

Tag fields provided in 'iTunes API' mode:

["#_COVERURL"]: custom tag, can be removed in Settings
["#_SOURCE"]: custom tag, can be removed in Settings
["_COLLECTIONADVISORY"]: custom tag, can be unselected from results
["TOTALCOLLECTIONTRACKS"]: custom tag, can be removed in Settings
["ALBUM"]
["ALBUMARTIST"]
["ARTIST"]
["COPYRIGHT"]
["COUNTRY"]: custom tag, can be unselected in results. Uses ISO 3166-1 alpha-3 format
["DISCNUMBER"]
["GENRE"]: can have different format/values, according to source
["ITUNESADVISORY"]
["ITUNESALBUMID"]
["ITUNESARTISTID"]
["ITUNESCATALOGID"]
["ITUNESMEDIATYPE"]
["TOTALDISCS"]
["TOTALTRACKS"]
["TRACK"]
["TITLE"]
["YEAR"]: formatted as YYYY-MM-DDTHH:MM:SSZ, as provided by the source

Tag fields provided in 'Apple Music Web' mode:

["#_COVERURL"]: custom tag, can be removed in Settings
["#_SOURCE"]: custom tag, can be removed in Settings
["_COLLECTIONADVISORY"]: custom tag, can be unselected from results
["TOTALCOLLECTIONTRACKS"]: custom tag, can be removed in Settings
["ALBUM"]
["ALBUMARTIST"]
["ARTIST"]
["COMPOSER"]
["COPYRIGHT"]
["COUNTRY"]: custom tag, can be unselected in results. Uses ISO 3166-1 alpha-2 format
["DISCNUMBER"]
["GENRE"]: can have different format/values, according to source.
["ISRC"]
["ITUNESADVISORY"]
["ITUNESALBUMID"]
["ITUNESARTISTID"]
["ITUNESCATALOGID"]
["ITUNESCOMPOSERID"]
["ITUNESMEDIATYPE"]
["TOTALDISCS"]
["TOTALTRACKS"]
["TRACK"]
["TITLE"]
["YEAR"]: formatted as YYYY-MM-DDTHH:MM:SS.mmmZ, as provided by the source

Many thanks for your work.
I am not so familiar with the possible features of the websource-settings. Would it be possible to have a multiple-choice-selection in the search-by-box for country and language?
Otherwise I have to learn the used abbreviations for country and language to change them during call.
My experience with apple and itunes is, that sometimes I have to select another country to get complete results.