jarun / buku

:bookmark: Personal mini-web in text
GNU General Public License v3.0
6.52k stars 294 forks source link

Adding or Updating a shortened URL #708

Closed rameshm76 closed 8 months ago

rameshm76 commented 10 months ago

Query

Opening this ticket, as I'm not sure if there a feature for the following:

I noticed that there are a lot of shortened URL's from google, oreilly, bit.ly, tiny url etc. For example https://goo.gl/Rn2FFN and https://oreil.ly/2A6hjLd etc. Is there a way to add the expanded link or redirect link?

buku -a https://oreil.ly/2A6hjLd buku -u https://oreil.ly/2A6hjLd

The final URL should be https://www.oreilly.com/content/data-engineering-a-quick-and-simple-definition/

LeXofLeviafan commented 9 months ago

These links appear to be using HTTP 301 for redirection…

Would a command to update existing record(s) based on permanent HTTP redirects suffice for you? It's been requested as part of #702.

rameshm76 commented 9 months ago

That should be fine.

Two issue I can think of:

  1. A shorten URL expanded to an existing URL use case
  2. A shorten URL may prompt user input to proceed to actual URL.

Not sure how to handle 2.

LeXofLeviafan commented 9 months ago

The 2nd case doesn't sound like an HTTP redirect, and isn't really detectable as such; if the user wants to replace such a URL he'd have to do it manually.

As for the 1st one… well, it'd have to either result in an error or an (optional?) user prompt to confirm merging/updating the existing records.

LeXofLeviafan commented 8 months ago

The final URL should be https://www.oreilly.com/content/data-engineering-a-quick-and-simple-definition/

Turns out the actual result of HTTP redirects looks a bit different: wget

It appears that there's a bunch of utm_* query parameters that gets removed within the browser (likely by javascript).

LeXofLeviafan commented 8 months ago

…Completed with #702:

$ buku -a https://oreil.ly/2A6hjLd --url-redirect
2. Data engineering: A quick and simple definition – O’Reilly
   > https://www.oreilly.com/content/data-engineering-a-quick-and-simple-definition/?utm_source=telegram.me&utm_medium=social&utm_campaign=mdtrue-silenttruep-hacking-and-false&utm_content=21259580
   + Get a basic overview of data engineering and then go deeper with recommended resources.

(The final URL isn't exactly the same as requested; I've explained the reason in my previous comment.)