Can't point pointer at tag values or output buffers?

Hi all and thanks in advance,

I’ve been getting my head around using web sources to put ID3 tags onto videos. I’ve looked over the official Discogs scripts, several others from the community and now tinkering with @Sweder and @RobertM’s TMDB scripts to try and make an all-in-one script for both Movies and TV using TMDB’s “multi” search.

For movies? Easy, works no problem.

For TV? It’s a bit of a stinker. As much as I prefer TMDB, it had to be difficult.

TL;DR: The only way to get a TV show season from TMBD’s API is by constructing a URL that messes with the Web Sources Framework: you can’t query or put a TV season in [IndexURL], but you need the TV season for [AlbumURL]. This requires bypassing search or a method to insert a new value at any point in the script.

I’ve tried calling a second search prompt to ask for the value, using a %placeholder% tag value, sneaking it as a URL &parameter= into [ParserScriptIndex] and using “CurrentURL” as an output buffer.

No matter what, I can’t get my pointer pointing at anything other than the website’s HTML/JSON. Is there a way to point Line and position: to other data or could there please be a way to do so?

Full breakdown

There is the likes of Plex for video tagging but I’d rather have tag data contained in the files, not separate. There is also other media management software more catered towards video: no way, I got my workflow set up really nicely. MP3Tag to the core, baby.

I wanted to make a web source for TMDB that would tag both movies and TV shows. A movie is simple as you’re inputting and outputting for one file, with potential to return an array if you select multiple files or OutputTo “Tracks”.

(Movie franchises and collections are a thing but let’s not go there.)

I figured it would be easiest to search for TV shows by a single season to get those episodes. This would be easier than working with all seasons, there’s also a limit of 20 appended URL parameters (looking at you, The Simpsons):

Get all episodes of a series - Talk — The Movie Database (TMDB)

Get all seasons of the series without passing seasons number like season/1, season/2, season/3 - Talk — The Movie Database (TMDB)

Searching

Using TMDB’s “multi” search makes it easier to find multiple types of media. For example:

Search - Multi

https://api.themoviedb.org/3/search/multi?query=Game+of+Thrones&api_key=…

This finds the TV show, as well as other possible matches.

The alternative is two separate scripts for “movie” or tv” written into [IndexURL] for the corresponding search:

Search - Movies

https://api.themoviedb.org/3/search/movie?query=Game+of+Thrones&api_key=…

Search - TV Shows

https://api.themoviedb.org/3/search/tv?query=Game+of+Thrones&api_key=…

The same but with less possible results per search (which might be more desirable).

Once a search result is chosen:

  • For a “multi” search, json_select "media_type" and SayRest to append “movie” or “tv” to [AlbumURL]
  • For a dedicated “tv” script, it’s pre-written into [AlbumURL]:

TV Series Details

https://api.themoviedb.org/3/tv/{series_id}?api_key=…

This, however, will only return an overview of the TV show, no arrays of season/episode data.

The problem

Back to square one and now everything suffers the same problem: constructing the URL for a TV season. You can query a TV Show by name but you can’t include the season.

[SearchBy]= Season||%tvseason%||/season/%s will mess with [IndexURL] as it’s not possible to search for a season through the API:

https://api.themoviedb.org/3/search/multi/season/1?query=Game+of+Thrones&api_key=…

https://api.themoviedb.org/3/search/tv/season/1?query=Game+of+Thrones&api_key=…

All will return a bad URL, unless you leave %tvseason% blank to disable /season/%s. Regardless, nothing supports any notion of a season/episode in the query.

To get season data, the only solution is to go straight to [AlbumURL]:

https://api.themoviedb.org/3/tv/{series_id}/season/{season_number}&api_key=…

@RobertM has kindly made a script based on this: you can go straight to the goods but this bypasses search functionality and requires extra steps to obtain an IMDB ID. I am desperate for one-click solutions, sorry. :sweat_smile:

wat do??

So I’m no coder but I’ve had a rare old time with columns, actions, a little bit of exporting and now trying out web sources. Frankly, bashing together functions, trial-and-error and unhealthy amounts of research got me confident enough to give this a try. Here’s what I’ve tried as potential options:

Being a noob:

Making a second section of [SearchBy] and [ParserScriptIndex]. Thought it might have initiated a second prompt to search and add in values with some conditions:

If it’s a movie, continue to [ParserScriptAlbum]

If it’s a TV show, ask for a season/episode then put that into [ParserScriptAlbum]

Worth a try but not the case. Ho-hum.

%placeholders%:

Fair confirmation that tag values can’t be utilised except in [SearchBy]. It’d be fantastic though as %placeholders% are by far the most powerful part of MP3Tag functionality and are implemented in just about every other aspect of the software.

Sneak it into a URL:

This got me all excited so I tried [SearchBy]=Season||%tvseason%||&season=%s to sneak the season value into [IndexURL]:

https://api.themoviedb.org/3/search/tv?query=Game+of+Thrones&season=1&api_key=…

Thankfully, both the website and the API returned expected results and is still available in “CurrentURL” for the value to be appended to [AlbumUrl]

Unfortunately, I haven’t found any way to grab it as I can’t figure out how to point to it. Please let me know if I’ve missed something, this is the first time I’ve worked with pointers.

Output buffer as an %output%:

Promising but from my understanding, it refers to an output as a parameter for commands to manipulate the HTML/JSON, rather than pointing at and manipulating the output value. I thought this would let me finally mess with “CurrentURL” but unfortunately not. I also kept typing %output% rather than say, %test% or %_url% or %title% or %TEMP_blahblahblah%.

Looks like a feature suggestion…

By checking debug text files, I’ve tried every command to get data other than what’s returned from TMDB’s API loaded into Line and position: which is where I’ve arrived at.

If there were a way to make Line and position: point at the likes of “CurrentURL” or %tvseason%, this could work. Multiple prompts sounds cool but that’s an afterthought (besides, too many clicks).

I’ll take whatever outcome but I’ve had far too much fun and utility with this program to skip getting advice or taking the opportunity to raise the case for something that could help web sources become far more flexible.

P.S. Apologies for the long read and throwing a load of hyperlinks. Got a bit passionate about this one. :grimacing:

If it were possible to include fields in [SearchBy] other than for use by [IndexUrl], for example, a %TVSeason% sourced field, and flag these as being distinct from existing '%s' type [SearchBy] fields, so they'd be ignored in [IndexUrl] but could instead be referred to somehow in [ParserScriptIndex] when constructing result URL to detail, then it'd be possible to go straight from query search results to detail URLs such as https://api.themoviedb.org/3/tv/{series_id}/season/{season_number} rather than be restricted to detail URL formats only referencing {series_id}.

Sneaking fields in as dummy parameters is a crafty way of getting [IndexUrl] to effectively ignore them, but, as @arb notes, there's still issue of fishing out and utilising such values beyond that.
The availability of "CurrentURL" is tantalising, but I haven't been able to figure out a way to usefully select particular bits of information from it either.

Got it. Played around a lot more until I made better sense of things, then found this:

Finally found a command that can load whatever you want into the pointer:

BIG thanks to @rboss. I reattempted @anon40688970’s trick of a dummy parameter and got the whole thing working. I’ll post in the original TMDB thread with my version and any other findings in a day or so, working on stuff like a .settings file for storing the API key, language and tag mappings (prefer using %album% rather than %tvshow%).

I’d still vouch for a simpler way to point at things other than a website’s response; even though the point of a web source IS to look explicitly for new values, there’s sometimes only so much you can do with that given dataset.

Maybe a new command like PointAt that supports ID3 %placeholders% or output buffers from previous parser blocks to use as parameters or even save as tags at any part of the process…

Or a second prompt like [SearchAlbumBy] to let the user manually state more values after the first search phase to expand upon/combine results from the chosen results URL (seasons, episodes) or even during the search phase to carry values past it and straight into [AlbumURL].

Also bigger thanks to @RobertM for getting the ball rolling :grinning_face:

A bit late to the party, since @arb already

but if it can still be of use to you, please check my Cover Art Archive script, where I had to work out similar technical issues to get cover dimensions displayed as search results from an API that doesn't support querying for cover size.

Glad to see my ramblings be helpful to others; and looking forward to your finished product.

Oh, and welcome to the community. :+1: :wrapped_gift: