Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support GET requests to /add #372

Open
TheSpyder opened this issue Jan 9, 2024 · 8 comments
Open

Support GET requests to /add #372

TheSpyder opened this issue Jan 9, 2024 · 8 comments

Comments

@TheSpyder
Copy link

How hard would it be to implement GET support for adding videos, something like /add?url=myvideo&quality=best? This would allow the bookmarklet and extension to work without the HTTPS restriction (using window.open(), which can be any URL).

I only have a passing knowledge of Python but adding doesn't seem too complex, the hard part is probably displaying something useful on success (such as redirecting to the main page).

metube/app/main.py

Lines 110 to 114 in 4a3a27e

@routes.post(config.URL_PREFIX + 'add')
async def add(request):
post = await request.json()
url = post.get('url')
quality = post.get('quality')

@PikuZheng
Copy link
Contributor

just change post to get like
@routes.get(config.URL_PREFIX + 'add')

@TheSpyder
Copy link
Author

I thought of that, but then how would request.json() work? I'm not familiar with the framework at all.

@PikuZheng
Copy link
Contributor

well... still you can send a request body with GET
image

@TheSpyder
Copy link
Author

In theory, sure, but I specifically want to use query string parameters so I can avoid the HTTPS restriction with window.open('http://my-server:8081/add?video=window.location&quality=best') (or something similar, I'd probably need to URL encode the location).

@PikuZheng
Copy link
Contributor

sorry I misunderstood. these may help:

@routes.post(config.URL_PREFIX + 'add')
@routes.get(config.URL_PREFIX + 'add')
async def add(request):
    if request.method=="GET":
        post=request.query
    else:
        post = await request.json()
    url = post.get('url') .............not changed below

then you can use something like /add?url=http%3A%2F%2Fwww.youtube.com........&quality=best this is the minimal modification I think

@TheSpyder
Copy link
Author

aha! thank you. I might submit a pull request if it works 🤔

@Ilosariph
Copy link

@TheSpyder did you try it? Sounds like an easy solution to download videos.

@TheSpyder
Copy link
Author

no, I never got around to it before I stopped using the shortcut. I didn't use my phone much for sending videos to metube anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants