Giter Club home page Giter Club logo

Comments (8)

nfriedly avatar nfriedly commented on August 19, 2024 2

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)) {

from node-unblocker.

MassSmith avatar MassSmith commented on August 19, 2024 1

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:
071416

from node-unblocker.

nfriedly avatar nfriedly commented on August 19, 2024 1

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") {
+  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="${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

re_rel_root = /((href=|src=|action=|url\(\s*)['"]?)(\/.)/gi, // matches root-relative urls like /foo/bar.html

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.

from node-unblocker.

nfriedly avatar nfriedly commented on August 19, 2024 1

I went ahead and incorporated the changes so that everyone else will get it going forward. Thanks for testing things for me!

from node-unblocker.

MassSmith avatar MassSmith commented on August 19, 2024

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:
205231

205700

Thank you again! !

from node-unblocker.

MassSmith avatar MassSmith commented on August 19, 2024

In addition, there is no error output on the console。
211317

from node-unblocker.

MassSmith avatar MassSmith commented on August 19, 2024

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!!

from node-unblocker.

MassSmith avatar MassSmith commented on August 19, 2024

Thank you so much for everything you do!!
^_^

from node-unblocker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.