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

REQUEST to make LINKS GENERATED downloadable in browser #5

Open
tgmb1 opened this issue Jan 4, 2025 · 10 comments
Open

REQUEST to make LINKS GENERATED downloadable in browser #5

tgmb1 opened this issue Jan 4, 2025 · 10 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@tgmb1
Copy link

tgmb1 commented Jan 4, 2025

It's me again👋🏻
I used OAuthtool and my old client ID and client SECRET to get new code ,
used HACKERS KEYBOARD to copy and paste in CLOUDFLARE
(I don't have a PC , this app helps copy long codes)
This is the way to update the code , right Sir?

addon is now deployed and works perfectly in STREMIO , I'm so happy right now♥️

My third request today🙃 :
STREMIO asks me to choose which app to open the FILES with.
I always chose video players if I want to watch it , browsers if I want to download it.
I use REAL DEBRID and the links generated can be downloaded with browsers.

But when opening the LINKS GENERATED by stremio-gdrive-addon in browsers , the links loads 100% , but download won't start , and this issue is for 1-2 files per movie , I tested 10+ movies since last week. Sometimes , 1DM+ opens a video in the browser itself.

I tried Chrome - it shows 1 download pending or failed.
I tried 1DM - the links loads 100% and nothing happens.
The same links have no buffering while STREAMING.

Can you please make the LINKS GENERATED by stremio-gdrive-addon downloadable in BROWSERS and at the same time streamable using VIDEO PLAYERS

if it's not possible , add a option in CONFIG ,
to set links to DOWNLOAD only and I can deploy another add-on ,
one for streaming , one for downloading.

@Viren070
Copy link
Owner

Viren070 commented Jan 4, 2025

Unfortunately, I don't know how to make it downloadable. Using the method the previous gdrive addon used caused issues with using more than 10ms of CPU time, causing the streams to not work.

So I simply pass the request body from google drive through at the download URL. Some download managers, like JDownloader2, can download the video. Trying to download through the browser simply doesn't work, and I don't know how to make it work.

Maybe I did do something wrong initially when trying to replicate the previous addon, but for now, the current method works for streaming, and that is the only scope of this addon. I can leave this issue open if someone else knows how to fix it, and they can create a pull request to solve it.

@tgmb1
Copy link
Author

tgmb1 commented Jan 4, 2025

I think this might HELP (might be dumb too🙃 , I am not CODER)
I asked ChatGpt about this a few days back and
then I checked the code for words "Disposition" and "MIME"
I toggled PROXIED playback , issue wasn't resolved.
It would be really helpful if this issue can be fixed.

It said
The difference in behavior between the two scenarios could be due to differences in how playback URLs are being served or restrictions applied in the server's response headers. Here's how you can troubleshoot and resolve this:

Why "ABC" Can't Be Downloaded in Browser

  1. Proxied Playback Enabled:
    If proxied playback is used, the file stream may be served with headers that make it unsuitable for direct browser downloads.
  2. Response Headers:
    Certain headers like Content-Disposition or X-Content-Type-Options could prevent direct downloading:
    Content-Disposition: inline (forces browser playback).
    X-Content-Type-Options: nosniff (may cause issues with unsupported formats).

Why "XYZ" Can Be Downloaded

  1. Direct Access:
    If playback is being served directly from the file link (without a proxy or custom headers), the browser allows it to be downloaded.
  2. Headers for Download:
    If the server responds with Content-Disposition: attachment, it encourages downloading rather than playback.

How to Control Download Behavior
To make playback consistent across both scenarios (either always downloadable or not):

  1. Force Playback Only (Prevent Downloads):
    Use Content-Disposition: inline in the server response for playback.
    Example:
    res.setHeader('Content-Disposition', 'inline');
  2. Allow Both Playback and Downloads:
    Use Content-Disposition: attachment or omit it entirely.
    Example:
    res.setHeader('Content-Disposition', 'attachment; filename="movie.mp4"');
  3. Check MIME Type:
    Ensure correct MIME type is sent (video/mp4, etc.) to ensure playback compatibility in Stremio.
    Example:
    res.setHeader('Content-Type', 'video/mp4');
  4. Compare Header Configurations:
    Check differences in response headers between the two files (ABC and XYZ). Look for headers like Content-Disposition or Cache-Control.

Action Steps

  1. Inspect Headers: Use browser developer tools or a request logger to analyze the response headers for both playback scenarios.
  2. Ensure Consistency: Standardize playback handling by modifying your server response logic for all files.
  3. Debug Proxied Playback: If proxied playback is causing restrictions, investigate the proxy logic to ensure it aligns with your intended behavior.

@tgmb1
Copy link
Author

tgmb1 commented Jan 4, 2025

I know MEDIAFUSION DEV
Can I ask him to help you on this download issue , only if you don't mind😇

@Viren070
Copy link
Owner

Viren070 commented Jan 4, 2025

Sure. This is probably a simple fix, I'm just not that good at coding.

@tgmb1
Copy link
Author

tgmb1 commented Jan 4, 2025

I can't write 1000 lines of code that work perfectly , you are really good.
I have messaged him.
Hope he helps ASA he is free⏳

@Viren070
Copy link
Owner

Viren070 commented Jan 4, 2025

Thanks.

By the way, downloading won't be possible with proxiedPlayback disabled. With proxiedPlayback disabled, you need to send your access token in the authorization headers to be able to access the file.

This is the relevant code that creates the proxied response

async function createProxiedStreamResponse(fileId, filename, request) {
try {
const accessToken = await getAccessToken();
const streamUrl = API_ENDPOINTS.DRIVE_STREAM_FILE.replace(
"{fileId}",
fileId
).replace("{filename}", filename);
const headers = {
Authorization: `Bearer ${accessToken}`,
Range: request.headers.get("Range") || "bytes=0-",
};
const response = await fetch(streamUrl, { headers });
if (!response.ok) {
throw new Error(`Failed to fetch file: ${response.statusText}`);
}
return new Response(response.body, {
headers: {
"Content-Range": response.headers.get("Content-Range"),
"Content-Length": response.headers.get("Content-Length"),
},
status: response.status,
statusText: response.statusText,
});
} catch (error) {
console.error({
message: "Failed to create proxied stream response",
error: error.toString(),
});
return new Response("Internal Server Error", { status: 500 });
}
}

Although there could be a way to download the stream with Stremio, as it has a download this link button on some platforms, I forget which though.

@tgmb1
Copy link
Author

tgmb1 commented Jan 4, 2025

1DM+ can download with proxiedPlayback disabled using GRABBER , but issue is file name is like hsososbeksksbshMOVIENAMEjdkdjddheisk😅
but the other issue of download not starting still exists

STREMIO Android doesn't have a download button🙂
I use the same app in FireStick

@Viren070
Copy link
Owner

Viren070 commented Jan 4, 2025

Oh, in response to your original comment. Yes you can update the code by just using the OAuth tool again.

That would be the simplest and easiest way to do it.

Yeah with proxied playback disabled, the filename is just the ID of the file in google drive, we can't change that. I do provide the filename query string to the URL though.

@tgmb1
Copy link
Author

tgmb1 commented Jan 4, 2025

It's my fault , I missed the commit where you have added line saying to "remove existing code"
yes it's simple , copy , CTRL + A , delete , CTRL + V 🙌🏻

yes , I enabled it then.

I always wanted to stream files from TELEGRAM to STREMIO
Now I keep all TG files in DRIVE and your add-on does the work ✨
Thankyou once again🙏🏻

@Viren070
Copy link
Owner

Viren070 commented Jan 4, 2025

No problem.

@Viren070 Viren070 added help wanted Extra attention is needed bug Something isn't working labels Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants