Giter Club home page Giter Club logo

Comments (17)

Tzahi12345 avatar Tzahi12345 commented on July 24, 2024 1

Just tested the latest version (3.3) with the already existing API endpoints. They work! But only if called from the server itself. I'll eventually implement a public API (~v3.5 ish), hopefully we can make do with this system for now.

I put up some info on it on the README here. Will keep this issue open until a real public API is implemented.

from youtubedl-material.

Tzahi12345 avatar Tzahi12345 commented on July 24, 2024 1

Ok, I see.

Basically, the bash command you are running is not properly converting $*, it basically thinks you are trying to put in the string $* as the URL instead of the url argument you're trying to pass. Modify your script such that the xterm/curl command is formatted as a string rather than being a command itself. Then you can run eval to run the string as a command, with the proper args inserted.

I wrote up an example script here:

# Run YoutubeDL-Material Video download in bash script
echo Downloading URL: $*

command="curl -XPOST -H \"Content-type: application/json\" -d '{\"url\": \"$*\"}' 'http://127.0.0.1:17442/api/tomp4'"

eval $command

That should fix your issue. Let me know if it doesn't work or you run into any other problems!

from youtubedl-material.

Tzahi12345 avatar Tzahi12345 commented on July 24, 2024 1

the xterm window stays open like 30 to 60 secs. Should not it just submit and close with the lines above?

This is likely because the API call only returns when the video finishes downloading. This is currently how the backend tells the client when the video actually finished and the client should start streaming/downloading it.

I'm planning on refactoring this in the future, so the /tomp3 and /tomp4 endpoints will return immediately, and I will use another endpoint that will check on the status/progress of the downloading file so it knows when it is done.

Maybe there's a way to tell xterm to do it quietly so it doesn't stay open, at least in the meantime?

Also does this queue downloads properly? As in can I submit ulr after url after wihtout waiting one to download first?

It doesn't queue, it actually runs the downloads simultaneously (AFAIK). I do want to add a queuing system in the future, but it isn't in the pipeline yet. In short, you are safe submitting multiple requests after another. Nothing should break unless YouTube gets mad after all the requests, which can happen after dozens of videos are downloaded in quick succession.

from youtubedl-material.

gerroon avatar gerroon commented on July 24, 2024 1

Thanks for the reply. All that sounds fine, maybe some of this can be in thw API doc.

thanks

from youtubedl-material.

Tzahi12345 avatar Tzahi12345 commented on July 24, 2024 1

No problem! Glad to help. I've updated the docs to avoid any further confusion. The front page now explains how to authenticate, and the tomp3/tomp4 endpoints have their caveats explained as well.

from youtubedl-material.

Tzahi12345 avatar Tzahi12345 commented on July 24, 2024

There are URL params you can use to be able to auto start a download on launch. You can use this to automate the process, but it does require going to the webpage. I'll keep this idea in mind, hopefully I can get it in the next update.

Any particular API calls (other than downloading) that would interest you?

from youtubedl-material.

gerroon avatar gerroon commented on July 24, 2024

Hi

I am personally interested in some kind of way to pass Youtube url to download it remotely.

As an example, I use another Youtube download with the line below

curl -X POST --data-urlencode "url=$*" http://192.168.1.100:6000/youtube-dl/q

This works but your application much nicer to use as a web frontend.

from youtubedl-material.

gerroon avatar gerroon commented on July 24, 2024

THanks forr the reply.

Will this queue the requests or does it need to finish the existing one to be able to accept/submit another url via command line?

from youtubedl-material.

gerroon avatar gerroon commented on July 24, 2024

Hi

I tried to use this in a command line but this is what I get

I use $* to pass the url pass from the command line, which works in other youtube scripts.

ERROR: u'$*' is not a valid URL. Set --default-search "ytsearch" (or run  youtube-dl "ytsearch:$*" ) to search YouTube

Here is the line

xterm -e curl -XPOST -H "Content-type: application/json" -d '{"url": "$*"}' 'http://127.0.0.1:12000/api/tomp4'

from youtubedl-material.

Tzahi12345 avatar Tzahi12345 commented on July 24, 2024

Just curious, what's the benefit of using $* over manually putting in the URL? Reason I ask is because it isn't currently possible to pass bash arguments like that into the youtube-dl download command (it is running in a separate shell after all, so even if it could, $* would probably refer to app.js).

So if you could make do with manually putting in the URL in the curls, then that should work fine. Otherwise, maybe you can make a wrapper script that will take $* from the command line and inject it into that xterm command. Just a thought.

from youtubedl-material.

gerroon avatar gerroon commented on July 24, 2024

I would like to use it in a script, it kind of does not make sense to manually type a url into a bash script if you will.

I use a Firefox addon (called External Application Button) that lets me pass a youtube video url to a bash script. That is what I am trying to do atm.

from youtubedl-material.

Tzahi12345 avatar Tzahi12345 commented on July 24, 2024

Just finished implementing the public API! I've put the documentation up here. All the endpoints are there with their input and outputs, but it could use some introductory text and other hints.

In the next update (which is just about feature-complete now), you can enable the public API and generate an API key in the settings menu. This API key is the authorization token which you need to use the public API outside of localhost.

Thanks for the suggestion! I'm gonna close this issue, but feel free to open up another one if you have any other ideas/comments about the API.

from youtubedl-material.

gerroon avatar gerroon commented on July 24, 2024

Hi

So how do I use the new API key with the lines I have been using? I checked the doc but I am not seeing any example.

command="xterm -e curl -XPOST -H \"Content-type: application/json\" -d '{\"url\": \"$*\"}' 'http://192.168.2.1:12000/api/tomp4'"
eval $command

from youtubedl-material.

Tzahi12345 avatar Tzahi12345 commented on July 24, 2024

I should update the docs to show this. Basically, you need to add an authorization token, it looks something like this:

-H "Authorization: API_KEY"

Just replace API_KEY with your actual key, and make sure there's a space between 'Authorization:' and the API key.

Let me know if you have any issues implementing this!

from youtubedl-material.

gerroon avatar gerroon commented on July 24, 2024

Thanks. I am getting "empty reply from the server with the new addition"

"curl -XPOST -H \"Authorization: 22d45dd2-d11d-426f-82ef-d5c391ad5c0e Content-type: application/json\" -d '{\"url\": \"$*\"}' 'http://192.168.2.1:12000/api/tomp4'"

from youtubedl-material.

Tzahi12345 avatar Tzahi12345 commented on July 24, 2024

Thanks. I am getting "empty reply from the server with the new addition"

Can you try separating the -H into two separate args? Like so:

"curl -XPOST -H \"Content-type: application/json\" -H \"Authorization: 22d45dd2-d11d-426f-82ef-d5c391ad5c0e\" -d '{\"url\": \"$*\"}' 'http://192.168.2.1:12000/api/tomp4'"

Let me know if this helps

from youtubedl-material.

gerroon avatar gerroon commented on July 24, 2024

Thanks I think that works, but it seems like the submission is extremely slow, the xterm window stays open like 30 to 60 secs. Should not it just submit and close with the lines above?

Also does this queue downloads properly? As in can I submit ulr after url after wihtout waiting one to download first?

from youtubedl-material.

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.