Jump to content

Youtube search, sort by date added


Recommended Posts

Posted

How do I make a custom search for Youtube and sort by date added?
I see the URL structure would be:

https://www.youtube.com/results?q={query}&sp=CAI%3D, but when you add more than word the URL becomes https://www.youtube.com/results?q=lizard+food&sp=CAI%3D, which will search for “lizard food” and sort by date added. Now the problem I see is I need Alfred to be smart enough to add a + to the URL if the query has more than one word. Any ideas?

Posted

What’s the issue, then? Alfred is smart enough to add the +, though it adds %20 by default (those are equivalent).


How are you trying to do this, that it’s not working for you?

Posted (edited)

I could not figure out how to have Alfred interpret if I added another word, and then have to add a + or %20 to it. Does that make sense? Basically I know how the URL structure should be but I'm at a loss to have it see I'm adding an extra word so it adds a + to each additional word.

In my mind I should have the program look for a space and if it detects it replace it with a + or the %20 equivalent.

Edited by mrapplegate
Posted (edited)

+ or %20 is a URL-encoded space.

 

If you enter a multi-word query, Alfred will automatically replace spaces with %20 because the URL wouldn't be valid otherwise.

 

If you want + instead, all you need to do is open your Custom Search options and change the Encode spaces as option to + instead of %20 (the default).

 

In practice, I don't think any websites care whether you use %20 or +.

Edited by deanishe
Posted
1 hour ago, deanishe said:

If you enter a multi-word query, Alfred will automatically replace spaces with %20 because the URL wouldn't be valid otherwise.

 

Precisely. Hence my question, @mrapplegate. If it’s not working for you, we need to know exactly what you’re doing in Alfred to diagnose what you’re doing wrong.

 

1 hour ago, deanishe said:

In practice, I don't think any websites care whether you use %20 or +.

 

Funny you mention that, because I have found one recently. In it, %20 counts as a literal space, but + counts as a literal + and even appears as such on the page. %2B produces the same result. Only reason I noticed was I was getting wrong results when URL-encoding a string to search.

Posted
8 hours ago, deanishe said:

+ or %20 is a URL-encoded space.

 

If you enter a multi-word query, Alfred will automatically replace spaces with %20 because the URL wouldn't be valid otherwise.

 

If you want + instead, all you need to do is open your Custom Search options and change the Encode spaces as option to + instead of %20 (the default).

 

In practice, I don't think any websites care whether you use %20 or +.

Now I understand, my problem was I was thinking I needed something complex to work. I had no idea Alfred would add the necessary %20 if the input had more than word. I was over thinking the whole process. My bad. Thanks all for the help. 

Posted
6 hours ago, vitor said:

 

Precisely. Hence my question, @mrapplegate. If it’s not working for you, we need to know exactly what you’re doing in Alfred to diagnose what you’re doing wrong.

 

 

Funny you mention that, because I have found one recently. In it, %20 counts as a literal space, but + counts as a literal + and even appears as such on the page. %2B produces the same result. Only reason I noticed was I was getting wrong results when URL-encoding a string to search.

Thanks Vitor, I had not tried anything yet because I was overthinking something that was so simple. My mistake. Thanks for your help. 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...