What’s the best way to handle region/language codes? I’d like to be able to set/save it in the .settings file, then have [IndexUrl] access the key value as part of the url. It gives a bad request error. Is there any way around having separate .src files per region/language code?
Depends what website you’re needing it from, how many languages are available and how many languages you actually want/need to use.
There’s currently no way to grab a string value from a .settings file in a .src, unless you type up a very long list of possible languages and an even longer list of IfVar…
Try another field in [SearchBy]:
Language||english||&language=%s
or store a %placeholder% in each file to reference:
Language||%language%||&language=%s
It means you’d have your main choice of language in the .src then you can easily change it via your search prompt when required. There’s a maximum of 5 fields so be wary of that too.
In regards to the error, we can help but need to know more about how your website’s URL needs formatted ![]()
Thanks for the response. The web source I’m working on is for Qobuz. The index url would be formatted as https://www.quboz.com/…/search?q=%s
Examples:
https:/www.quboz.com/en-us/search?q=%s
https://www.quboz.com/fr-fr/search?q=%s
etc.
There are 30 possible region/language possibilities for this site and I was hoping not to have to do .src for each language type, but if that’s how it has to be, that’s how I’ll do it. The languages will determine how some of the data is parsed, as well as differing search results per country.
Had a look at the website and they’ve changed the the URL format:
I tried out a starting block that might help you:
[Name]=Qobuz
[BasedOn]=www.qobuz.com
[IndexURL]=https://www.qobuz.com/%s
[AlbumUrl]=https://www.qobuz.com
[WordSeperator]=%20
[SearchBy]=Language||us-en||%s||Type||albums||/search/%s||Name||%album%||/%s
[Encoding]=url-utf-8[ParserScriptIndex]=...
It’s likely better off with separate .src’s per language as a simpler, hard-coded solution, then just round down 30 languages to a select few preferences. There’s also no way to place a .setting value into any of the starter formatting which is a bummer.
Good luck with your script, HTML looks a bit freaky. ![]()
Edit: Sorry, needed to be only %album% to match “albums” search. Might need separate scripts again to handle “artists” and “tracks”
So is it safe to say that .settings key/values (i.e., configuration schema) can only be accessed from [ParserScriptIndex] and [ParserScriptAlbum] using IfVar like in the “Developing Tag Sources” guide?
Sadly, yes. Hopefully the options for accessing .settings values will be expanded upon in the future. Until then, it’s workarounds with other functionality, extra scripting or extra .src’s.
Here’s the original thread where settings and possibilities were discussed:
SUGGESTION - JSON file to control settings of WS scripts - General Discussion - Mp3tag Community
This might be worth a try to loop through possible values until you reach your .settings value.
Correct.
Currently only [ParserScriptIndex] and [ParserScriptAlbum] can use parser commands (as their namesake implies). The syntax of [IndexUrl] and [SearchBy] works as described in the websources development page, where %s (and only this string marker) will be replaced with the corresponding values from the text boxes in "Search by" window.
As for your question, for now you can:
- make a .src file for each localization (which, as you have stated, is not desirable);
- use multiple query fields and have the localization string as an input variable; with the downside of having to input a new localization key 'by hand' (you can have the most used one as a preset). With this workaround you'll only need one .src file, but it might not suit your requirements.
Hope this helps.