Closed MassSmith closed 5 months ago
Another small bug was found https://****.***.***/proxy/https://www.youtube.com/watch?v=XGxIE1hr0w4 In areas where youtube cannot be accessed, the cover image cannot be displayed. Here is the webpage source code:
Aah, good points. For the first one, you might just need to change this line to include /embed urls:
- if (hostname === "www.youtube.com" && pathname === "/watch") {
+ if (hostname === "www.youtube.com" && (pathname === "/watch" || pathname === "/embed")) {
For the second one, I think you need to add /proxy/
to the start of the poster url here:
- <video controls poster="${thumb.url}" style="width: 100%">
+ <video controls poster="/proxy/${thumb.url}" style="width: 100%">
Also, I think we should add poster=
to this regex, although I don't think it affects the youtube page
I don't have time to test these out right now, but that's my best guess as to the fixes; feel free to try them out if you have the time.
Thank you very much for helping me in your busy schedule. I have done what you told me and the cover image problem has been solved. But the first problem still exists. The corresponding source code has been changed to: “if (hostname === "www.youtube.com" && (pathname === "/watch" || pathname === "/embed")) {” But when proxying a URL in the format of https://www.youtube.com/embed/XGxIE1hr0w4, it cannot be played. Here are the test results:
Thank you again! !
In addition, there is no error output on the console。
Oh, I see. For /watch
, the video id is in the querystring, but for /embed
it's in the path, so my check wouldn't work.
Instead of trying to guess whether or not it's a youtube URL ourselves, we should just ask ytdl. And, come to think of it, we could drop the first part and make this page work for other domains like youtu.be and m.youtube.com:
Can you try this and let me know if it works?
- if (hostname === "www.youtube.com" && (pathname === "/watch" || pathname === "/embed")) {
+ if (ytdl.validateURL(data.url)) {
Oh, I see. For
/watch
, the video id is in the querystring, but for/embed
it's in the path, so my check wouldn't work.Instead of trying to guess whether or not it's a youtube URL ourselves, we should just ask ytdl. And, come to think of it, we could drop the first part and make this page work for other domains like youtu.be and m.youtube.com:
Can you try this and let me know if it works?
- if (hostname === "www.youtube.com" && (pathname === "/watch" || pathname === "/embed")) { + if (ytdl.validateURL(data.url)) {
Really Great!!! Works perfectly!!! This problem is perfectly solved!! Thank you again!!
I went ahead and incorporated the changes so that everyone else will get it going forward. Thanks for testing things for me!
Thank you so much for everything you do!! ^_^
node-unblocker is a great project, I love it, I have been using it for more than 6 years. Recently I tried the youtube proxy function, it is very useful and smooth, but one of the youtube url formats does not seem to work properly, for example: https://www.youtube.com/embed/XGxIE1hr0w4 and this format is very common, many videos embedded on web pages are in this URL format. I really hope to add this function, thank the project author for his great contribution. (My English is very poor, the above is translated by a translator)