Difference in behavior between opening url with Hyperlinq and browser

JeffMercado
edited September 25 in General

I have a script that helps me bunch up a group of urls (YouTube videos) and crafts a new url that would then generate a playlist out of it.

That script would generate a URL such as:

https://www.youtube.com/watch_videos?video_ids=As4tO4wqQUY,_TMZsPjoGJA

If you open it in your browser, it will redirect to a url watching the first video and a generated playlist for those videos. It will have the &list=[playlist id] in the query string.

Problem is, if I put this url in a Hyperlinq which I could then open from LINQPad to my default browser, it only navigates to watching the video but no playlist appears to be generated.

new Hyperlinq("https://www.youtube.com/watch_videos?video_ids=As4tO4wqQUY,_TMZsPjoGJA").Dump();

Funnily enough, I could open it within LINQPad through Util.DisplayWebPage() and it generates fine, except I don't have direct access to the URL since we cannot manipulate the page at all.

This is probably not a problem necessarily with LINQPad but how the browser is launched or something. Opening the url from a command line works still.

Could this be looked at?


Of course, I could write the code to send the request directly and extract the redirect url, then work with that, but the behavior would probably be surprising to others who are unaware.

var handler = new HttpClientHandler();
handler.AllowAutoRedirect = false;
var client = new HttpClient(handler);
var response = await client.GetAsync("https://www.youtube.com/watch_videos?video_ids=As4tO4wqQUY,_TMZsPjoGJA");
if (response.StatusCode == System.Net.HttpStatusCode.SeeOther)
    new Hyperlinq(response.Headers.Location.ToString()).Dump();

Comments

  • JeffMercado
    edited September 25

    Funny, I noticed when I pasted the example link, the & was escaped, and the link, when opened navigates to the video, no playlist. I wonder if something similar is happening in some process?

    i.e., In the event of a redirect, the redirect url is escaped when it shouldn't be.

  • Is there a difference between the behavior in LINQPad 8 vs LINQPad 9?

    LINQPad 9 does the following to open the URI. You might like to try this directly:

    Process.Start (new ProcessStartInfo (uri) { UseShellExecute = true });
    
  • JeffMercado
    edited September 25

    Hmm it is different. LINQPad 8 works as expected, 9, it doesn't. I haven't changed a lot of settings with 9, is there something else I could be looking at?

    edit:
    Oh wait... I just updated to 9.2.17 just now, it's working as expected.

  • Sorry, I spoke too soon. It may be an issue with how I generate the hyperlinq in my script.

    I'll need to investigate further.

  • Ahhh, ultimately the problem was how I was invoking the url. I was calling:

    Process.Start(@"explorer.exe", $"\"{url}\"");
    

    Apparently longer urls or if it had certain characters might have broken it. Thanks for the shell execute, I was trying to do that in a roundabout way. 😅