Giter Club home page Giter Club logo

youtube-dl-server's Introduction

youtube-dl-server

A youtube-dl web server, powered by youtube-dl.

Intended to provide raw video url and other metadata as a json payload, not as a streaming server.

Getting started

npm install -g youtube-dl-server
youtube-dl-server

Deploy

API

GET /v1/video?url=<YOUTUBE_URL_HERE>&options=<OPTIONS>&schema=KEY1&schema=KEY2&cli=<yt-dlp|youtube-dl>

Returns a json payload with requested information.

- url: required - Url of youtube video
- options: optional - options to be passed to youtube-dl. Defaults to -f "best". See https://github.com/ytdl-org/youtube-dl/blob/master/README.md
- schema: optional - array of keys to be returned, to avoid returning all the json dump from youtube-dl. E.g. /v1/video?url=https://www.youtube.com/watch?v=1PuGuqpHQGo&schema=url&schema=title
- cli: optional - the cli tool to be used. "youtube-dl" | "yt-dlp". Defaults to "yt-dlp"

----

GET /watch?v=<YOUTUBE_VIDEO_ID_HERE>&options=<OPTIONS>&cli=<yt-dlp|youtube-dl>

Redirects to the raw video url.

- v: required - Url or ID of the video, same as the url parameter of GET /v1/video
- options: optional - options to be passed to youtube-dl. Defaults to -f "best". See https://github.com/ytdl-org/youtube-dl/blob/master/README.md
- cli: optional - the cli tool to be used. "youtube-dl" | "yt-dlp". Defaults to "yt-dlp"

youtube-dl-server's People

Contributors

ibicha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

youtube-dl-server's Issues

Android failure with a YouTube Livestream via Heroku server

Getting an error parsing a YouTube livestream on Android via a (personal) heroku server, Editor Win works like a charm:

logcat:


2023/03/11 19:13:19.704 15815 15836 Error Unity Exception: HTTP/1.1 404 Not Found
2023/03/11 19:13:19.704 15815 15836 Error Unity ResponseError:<!DOCTYPE html>
2023/03/11 19:13:19.704 15815 15836 Error Unity <html>
2023/03/11 19:13:19.704 15815 15836 Error Unity   <head>
2023/03/11 19:13:19.704 15815 15836 Error Unity     <meta name="viewport" content="width=device-width, initial-scale=1">
2023/03/11 19:13:19.704 15815 15836 Error Unity     <meta charset="utf-8">
2023/03/11 19:13:19.704 15815 15836 Error Unity     <title>Heroku | Application Error</title>
2023/03/11 19:13:19.704 15815 15836 Error Unity     <style media="screen">
2023/03/11 19:13:19.704 15815 15836 Error Unity       html,body,iframe {
2023/03/11 19:13:19.704 15815 15836 Error Unity         margin: 0;
2023/03/11 19:13:19.704 15815 15836 Error Unity         padding: 0;
2023/03/11 19:13:19.704 15815 15836 Error Unity       }
2023/03/11 19:13:19.704 15815 15836 Error Unity       html,body {
2023/03/11 19:13:19.704 15815 15836 Error Unity         height: 100%;
2023/03/11 19:13:19.704 15815 15836 Error Unity         overflow: hidden;
2023/03/11 19:13:19.704 15815 15836 Error Unity       }
2023/03/11 19:13:19.704 15815 15836 Error Unity       iframe {
2023/03/11 19:13:19.704 15815 15836 Error Unity         width: 100%;
2023/03/11 19:13:19.704 15815 15836 Error Unity         height: 100%;
2023/03/11 19:13:19.704 15815 15836 Error Unity         border: 0;
2023/03/11 19:13:19.704 15815 15836 Error Unity       }
2023/03/11 19:13:19.704 15815 15836 Error Unity     </style>
2023/03/11 19:13:19.704 15815 15836 Error Unity   </head>
2023/03/11 19:13:19.704 15815 15836 Error Unity   <body>
2023/03/11 19:13:19.704 15815 15836 Error Unity     <iframe src="//www.herokucdn.com/error-pages/no-such-app.html"></iframe>
2023/03/11 19:13:19.704 15815 15836 Error Unity   </body>
2023/03/11 19:13:19.704 15815 15836 Error Unity </html>
2023/03/11 19:13:19.704 15815 15836 Error Unity   at YoutubePlayer.YoutubeDl.GetVideoMetaDataAsync[T] (System.String youtubeUrl, YoutubePlayer.YoutubeDlOptions options, System.Collections.Generic.IEnumerable`1[T] schema, YoutubePlayer.YoutubeDlCli cli, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
2023/03/11 19:13:19.704 15815 15836 Error Unity   at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext

Why would I be getting a 404 on an Android? Timeout too short?

Getting a 404 using unity-youtube-dl-server.herokuapp.com

Latest version, trying to pipe in a HLS stream via await YoutubePlayer.YoutubePlayer.GetRawVideoUrlAsync(url);. Works without going through a Heroku server.

v2.0.2

Exception: yt-dlp.exe existed with code 1. 
null

ERROR: [generic] None: Unable to download webpage: HTTP Error 404: Not Found (caused by <HTTPError 404: 'Not Found'>); please report this issue on  https://github.com/yt-dlp/yt-dlp/issues?q= , filling out the appropriate issue template. Confirm you are on the latest version using  yt-dlp -U

YoutubePlayer.LocalYoutubeDl.GetVideoMetaDataAsync[T] (System.String youtubeUrl, YoutubePlayer.YoutubeDlOptions options, System.Collections.Generic.IEnumerable`1[T] schema, YoutubePlayer.YoutubeDlCli cli, System.Threading.CancellationToken cancellationToken) (at ./Library/PackageCache/[email protected]/Runtime/YoutubeDl/LocalYoutubeDl.cs:49)

Huge CPU ussage

I tested on virtual machine (1CPU 3.2GHz i5-1135G7). One request the direct URL take 30% CPU usage for 2-3 sec.
Is there way to reduce it?

Updating heroku app

I think I found my issue with my setup used within unity. I have commented several times within the unity player git and I might have stumbled on my real issue.

I checked my heroku setup and it was running still. I then sent a request via the web to my app and got a returned Cannot GET /watch error on the page with a video I copied the video url after the =. I then tried your link from the youtube-dl-server page and it worked directly from your heroku app. So, I pasted the same info into my web request. same Cannot GET /watch error.

I then clciked your super easy to deply app button and generated a new app with a different name. Copied your example url info into my new app web request and boom, it worked.

So, I have no experience with heoku other than your super simple button. Is there a method of pulling in updated data from your repository from the cli in heroku? I would like to be able to keep my same app address and your app is still functioning correctly.

If there is a method of pulling in the changes time to time, could you put that info into the readme for reference? I am now going to see what happens with my unity app and if I can pull in videos again without having to externally download them before trying to play from a network file. Having the ability to do it on the fly is much more user friendly for my users.

thanks for all the work put into this. it is great and I need to go learn more about heroku...

I get an odd response

I am hoping that you just have some idea where I could look. I have dev and prod copies of my service. They have the identical code base (and youtube dlls).

using dev: http://localhost:3004/watch?v=d9MyW72ELq0&cli=yt-dlp will return the actual video. The service returns a redirect (as you know) for watch.

using prod: an error is thrown with Cannot GET /videoplayback as the message.

I just can't see the difference other than prod uses https but it is doing that for all the rest endpoints that work.

Unable to extract uploader ID

Hello, I have been using this package and it worked smoothly till today - now it states

{"error":"Command failed: /app/tools/bin/youtube-dl -f "best" --dump-single-json --no-warnings https://www.youtube.com/watch?v=b1vTbYMN3EU\nERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\n","stderr":"ERROR: Unable to extract uploader id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type youtube-dl -U to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.\n","stdout":""}

Any idea what to do with it? Seen some python related workaround on the yt dl repo but dont know how to apply it here. It worked today, just used the app as usual, changed nothing, but this appeared, have it hosted on heroku.

Thank you

question about bandwidth

Hi there I've cloned the project and I'm happy to say it works :-) I'd like to get a little information about the bandwidth requirements so I can select my best option for hosting.

First, is the site serving the entire video (I suspect that it is). I was hoping that it could translate the URL into something that could be served by the YouTube servers.

And if so, does that mean additional connections will download their own copies as well? I believe it doesn't stream the video (correct me if I'm wrong). Thanks.

Build on Heroku fails

Hello. Kudos on your efforts.

Due to availability issues I would love to have an independent instance of the youtube server. However the heroku deploy returns and error and halts.

The error output is:

`-----> Building on the Heroku-20 stack

-----> Determining which buildpack to use for this app

-----> Node.js app detected

-----> Creating runtime environment

   NPM_CONFIG_LOGLEVEL=error

   NODE_VERBOSE=false

   NODE_ENV=production

   NODE_MODULES_CACHE=true

-----> Installing binaries

   engines.node (package.json):  unspecified

   engines.npm (package.json):   unspecified (use default)

   

   Resolving node version 14.x...

   Downloading and installing node 14.16.0...

   Using default npm version: 6.14.11

-----> Installing dependencies

   Installing node modules

   

   > [email protected] postinstall /tmp/build_bf68ee68

   > npm run download

   

   

   > [email protected] download /tmp/build_bf68ee68

   > node ./tools/download.js

   

   /tmp/build_bf68ee68/tools/download.js:17

           throw err;

           ^

   

   Error: connect ECONNREFUSED 95.143.172.170:443

       at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {

     errno: -111,

     code: 'ECONNREFUSED',

     syscall: 'connect',

     address: '95.143.172.170',

     port: 443

   }

   npm ERR! code ELIFECYCLE

   npm ERR! errno 1

   npm ERR! [email protected] download: `node ./tools/download.js`

   npm ERR! Exit status 1

   npm ERR! 

   npm ERR! Failed at the [email protected] download script.

   npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

   

   npm ERR! A complete log of this run can be found in:

   npm ERR!     /tmp/npmcache.BgO0d/_logs/2021-03-26T12_40_09_496Z-debug.log

   npm ERR! code ELIFECYCLE

   npm ERR! errno 1

   npm ERR! [email protected] postinstall: `npm run download`

   npm ERR! Exit status 1

   npm ERR! 

   npm ERR! Failed at the [email protected] postinstall script.

   npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

   

   npm ERR! A complete log of this run can be found in:

   npm ERR!     /tmp/npmcache.BgO0d/_logs/2021-03-26T12_40_09_538Z-debug.log

-----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:

   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   

   Some possible problems:

   

   - Node version not specified in package.json

     https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version

   

   Love,

   Heroku

! Push rejected, failed to compile Node.js app.

! Push failed

`

(sorry for the formatting)

Final issue about the URL

I get all the JSON data returned (I'm parsing it on my service) and I can easily see the id, the title, a ton of other data and an element named webpage_url but that is just the url I passed in with the video code. I see a channel_url and that plays in a browser but it returns the video playing within the channel page.

Is it hidden in one of the format elements? It played on my headset fine when I used your service Heroku service.

Any help is appreciated.

error npm in getting started??

Hey @iBicha , great support from you, and thank you for the time. Well, because YouTube always update, and we don't want to always rebuild the game because the plugin should be updated, we try to migrate the way using YouTube-dl-server like your said before, but when I try npm install, there is error

npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! [email protected] postinstall: mkdir -p tools/bin && wget https://yt-dl.org/downloads/latest/youtube-dl -O tools/bin/youtube-dl && chmod a+rx tools/bin/youtube-dl
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

url with leading hyphen or underscore fail

I've got everything working finally (other issues were mine) BUT some YouTube ids begin with an underscore or hyphen. Both of these fail for me. It seems to get confused where the options end.

{
    "error": "Command failed: C:\\nodeApps\\videoApi\\tools\\bin\\yt-dlp.exe -f \"best\" --dump-single-json --no-warnings -i9Mqo99fKE\n\r\nUsage: yt-dlp.exe [OPTIONS] URL [URL...]\r\n\r\nyt-dlp.exe: error: no such option: -9\r\n",
    "stderr": "\r\nUsage: yt-dlp.exe [OPTIONS] URL [URL...]\r\n\r\nyt-dlp.exe: error: no such option: -9\r\n",
    "stdout": ""
}

a yt-dlp project mentions a way around it: e.g. yt-dlp -- -QxK8NvFbaU but we are just calling the library so I don't know how to format it in such a case or if it is supported in this version.

live stream of Youtube

Is it possible to use this package for live streaming on youtube?
we have a live stream on youtube son if it's possible to use this package for the stream live URL?

I'm not understanding the response

a heads up there is a pending bug fix in yt-dlp

Something apparently changed at YouTube... I'm getting the error discussed here as well.

yt-dlp/yt-dlp#6251

I'll probably have to wait until the master branch is released. Your download.js function can get it for me but I wouldn't know what to change to get a compiled version of the master branch. Bummer.

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.