metube icon indicating copy to clipboard operation
metube copied to clipboard

Support GET requests to /add

Open TheSpyder opened this issue 2 years ago • 8 comments

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). https://github.com/alexta69/metube/blob/4a3a27e71cadaea52db51e85ffdbaf0a49beeaf0/app/main.py#L110-L114

TheSpyder avatar Jan 09 '24 11:01 TheSpyder

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

PikuZheng avatar Jan 09 '24 12:01 PikuZheng

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

TheSpyder avatar Jan 09 '24 12:01 TheSpyder

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

PikuZheng avatar Jan 09 '24 14:01 PikuZheng

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

TheSpyder avatar Jan 09 '24 19:01 TheSpyder

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

PikuZheng avatar Jan 10 '24 09:01 PikuZheng

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

TheSpyder avatar Jan 10 '24 09:01 TheSpyder

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

Ilosariph avatar Apr 16 '24 16:04 Ilosariph

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.

TheSpyder avatar Apr 16 '24 21:04 TheSpyder