It is currently April 19th, 2024, 9:35 pm

Using Strings in URLs

Get help with installing and using Rainmeter.
SneakyPiglet
Posts: 3
Joined: January 6th, 2017, 2:17 am

Using Strings in URLs

Post by SneakyPiglet »

Hey --

I've been using Rainmeter for a while, but I'm just now getting back into it. I'm looking to use a variable string in a URL, and I'm running into a brick wall. Here's what I've got...

Code: Select all

[MeasureArtistSearch]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=ARTIST
Substitute=" ":"+"

[MeterArtistSearch]
Meter=String
MeasureName=MeasureArtistSearch
FontColor=0,0,0,0

[MeterAristBackground]
DynamicVariables=1
Meter=Image
MeasureName=MeasureArtistSearch
X=0
Y=163
W=376
H=18
SolidColor=0,0,0,100
LeftMouseUpAction=[https://rateyourmusic.com/search?searchtype=a&searchterm=[%1]]
I'm looking to make whatever string [MeasureArtistSearch] comes out with is used in the search function on LeftMouseUpAction, but I'm unsure if I can use variables in URLs in such a way... Is this possible?

Thank you.
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using Strings in URLs

Post by balala »

SneakyPiglet wrote:I'm looking to make whatever string [MeasureArtistSearch] comes out with is used in the search function on LeftMouseUpAction, but I'm unsure if I can use variables in URLs in such a way... Is this possible?
It is, but in a bit different way: don't use the %1 expression in the URL, replace it with [MeasureArtistSearch]. And although it's not always absolutely needed, usually it's a good idea to include the URL into quotation marks: LeftMouseUpAction=["https://rateyourmusic.com/search?searchtype=a&searchterm=[MeasureArtistSearch]"].
SneakyPiglet
Posts: 3
Joined: January 6th, 2017, 2:17 am

Re: Using Strings in URLs

Post by SneakyPiglet »

balala wrote:It is, but in a bit different way: don't use the %1 expression in the URL, replace it with [MeasureArtistSearch]. And although it's not always absolutely needed, usually it's a good idea to include the URL into quotation marks: LeftMouseUpAction=["https://rateyourmusic.com/search?searchtype=a&searchterm=[MeasureArtistSearch]"].
Awesome, thank you! I wasn't exactly sure what I was missing there, but it's good to see that it works. One more question for you, if you would -- upon playing with it a bit further, I realized I'd like to make the string lower-case rather than proper; do you know if there's any way I can apply StringCase=Lower to either [MeasureArtistSearch] or [MeterArtistBackground]? The main issue is that the meter is an image rather than a string, although I'm sure I could make a workaround for that.
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using Strings in URLs

Post by balala »

The StringCase option can be used only on string meters, nor on image meters, nor on measures, of any kind. But, at least as far as I can tell, there's no need to convert the string to lowercase. Or is it, for any reason?
SneakyPiglet
Posts: 3
Joined: January 6th, 2017, 2:17 am

Re: Using Strings in URLs

Post by SneakyPiglet »

In my experience, oddly enough, URLs on the site are case-sensitive - I'm currently trying to see if I can directly access an artist's page at https://rateyourmusic.com/artist/artist_name. However, artist_name works, while Artist_Name does not -- and that's what I was getting.

As I was writing this post, I realized that I could use Substitute for the roman alphabet, so I tried that out and it worked -- thank you so much for your help.
User avatar
balala
Rainmeter Sage
Posts: 16147
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Using Strings in URLs

Post by balala »

SneakyPiglet wrote:As I was writing this post, I realized that I could use Substitute for the roman alphabet, so I tried that out and it worked -- thank you so much for your help.
Maybe a much simpler solution could exist, to not have to substitute each letter one by one, but this would require using regular expressions (and the appropriate RegExpSubstitute option). For now, this is beyond me, maybe someone else, who knows much more about this workaround, will help.