Code Monkey home page Code Monkey logo

stremio-gdrive's Introduction

stremio-gdrive

image image

Instructions:

There are two ways to go about:

  • Method 1 is hard and long but might give you better performance and you need to make your own google cloud project thingy.
  • Method 2 relies on rclones google cloud project saving you the burden of having to create your own project i.e. you can skip straight to step 18.

Method 1 starts from here

  1. Go to https://console.cloud.google.com/projectcreate
  2. Name the project whatever you want and click create.
  3. Next to "Google Cloud Platform," click the Down arrow image and select your project.
  4. At the top-left corner, click the hamburger menu icon: image Click APIs & Services > Credentials.
  5. Click Configure Consent Screen. The "OAuth consent screen" screen appears.
  6. Set user type to external and click create.
  7. Fill in the required details, you can give your own email as dev and support email. Click save and continue.
  8. For the scopes page leave it as it is and click save and continue.
  9. Now add yourself (your email id) as the test user by pressing add users. Click save and continue.
  10. Now on your left, under API & Services, you will see Dashboard. Click on it and then click on Enable APIs and Services.
  11. Search for Google Drive and click on the result that says Google Drive API and then click on Enable.
  12. Now do step 4 again.
  13. Click Create Credentials > OAuth client ID.
  14. Choose application type as Desktop, name it whatever you want and click create.
  15. The newly created credential appears under "OAuth 2.0 Client IDs." Click the download button to the right of the newly-created OAuth 2.0 Client ID. We will get a client_secret.json file, we will need this for the next section.
  16. Now once again, at the top-left corner, click the hamburger menu icon: image Click APIs & Services > OAuth Consent Screen.
  17. Under Publishing Status you will see a button called PUBLISH APP, click on that and choose confrim.

Method 2 starts from here

  1. Use the colab notebook to easily obtain the token and the required code for the cloudflare proxy:

Open In Colab

  1. Run the cell of the respective method number you chose. Just press the circular play button beside the rectangular box.

  2. Login with your google account. Copy the js code and copy the token string for later when we deploy the heroku backend, the token should look something like this:

{"token": "jhgdfgdhgfh", "refresh_token": "1//sdhgbfdhghd", "token_uri": "https://oauth2.googleapis.com/token", "client_id": "hsdgfjhgfsd.apps.googleusercontent.com", "client_secret": "gfsdfsdgf", "scopes": ["https://www.googleapis.com/auth/drive"]}

Skip to Deploying to heroku if you dont want to use a proxy.

  1. Go to https://dash.cloudflare.com/ log in or sign up.
  2. Open the Workers option.
  3. Create your sub-domain or continue if already done.
  4. Select the Free Plan. Click on Create a Worker. You can rename the workers at top of the page.
  5. In the Script{} box you will see some code, delete all that and paste the js code that you obtained in step 18 there.

Deploying to heroku:

Deploy to Heroku

  1. Hit the deploy button.
  2. Paste the token string in the token field.
  3. Copy your cloudflare worker url and paste it in the cf proxy url field. Leave it blank to use the addon without the proxy.
  4. Hit deploy.

Installing the addon to your Stremio account:

  1. Get the url of the heroku app you deployed. Add /manifest.json to the end. For example if my herokuapp url is https://your-stremiogdrive.herokuapp.com add /manifest.json to the end to get: https://your-stremiogdrive.herokuapp.com/manifest.json. Copy this url.
  2. Open stremio on desktop or android and go to addons section.
  3. In the search bar paste the manifest link (https://your-stremiogdrive.herokuapp.com/manifest.json) and press enter. Click install and you are done.

How the addon works

The addon uses the drive api to search for video files in your drive (both your teamdrives and mydrive) kinda like using the google drive web search bar.

So after setting up the addon go and search for something on stremio. When you open a search result, stremio will ask the addon if it has the video for the search result. The addon searches for the video in your google drive and if it gets any result it will give it to stremio and stremio will display the results.

For example if I want to watch a movie, say its called Pirates of the Goolag, then:

  • I will open stremio and search for Pirates of the Goolag. If its on imdb then it should appear on the stremio search results (stremio fetches search results from imdb).
  • Open the search result for Pirates of the Goolag and stremio will ask the addon if it has a video stream for Pirates of the Goolag.
  • The addon searches in your Google Drive for Pirates of the Goolag and if its anywhere on your google drive, doesnt matter where as long as the video file has the name and year of the movie (for eg: Pirates of the Goolag 2016.mkv or Pirates.of.the.Goolag.2016.UHD.BluRay.x265.mkv), the addon will return the search results for Pirates of the Goolag.
  • Stremio will then display it as a video stream and all you have to do is tap on it and enjoy.

The addon searches for:

  • Movies by searching for Videos with their filename as the name of the movie and when it was released. Eg video filename: Pirates of the Goolag 2016.mkv

  • Series episodes by searching for Videos with their filename as the name of the series and which episode it was by a specifier. Supported specifiers are:

    • S01 E01
    • S1 E1
    • Season 1 Episode 1
    • 1x01
    • 1x1

Issues / Limitations / Explanations

  • Apps hosted on heroku sleeps after 30 mins of inactivity. So after 30 mins of inactivity the addon needs about 30 secs to start back up and then some time to fetch the results. If you use something like Kaffeine you can overcome this as Kaffeine pings your app every 30 mins. Downside is that you will spend extra dyno hours. Free dynos have about 550 hours of runtime per month which is about 22 days.
  • Google api is not very fast so if you have a ton of results it might take 10 - 15 secs to load.
  • Cloudflare workers is used as a proxy to stream files from google drive since it is really fast.
  • I am an amateur and I did this to the best of my ability. If you find flaws feel free to post an issue.

For the sake of security please don't share your herokuapp url or your cloudflare workers proxy url. They can be used to get files from your drive.

stremio-gdrive's People

Contributors

ssnjr2002 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stremio-gdrive's Issues

Can I deploy it on a RPi instead of Heroku?

Hi

Thank you so much for this amazing addon, I really appreciate it!

1- I have a Raspberry Pi that's running 24 hours, so I was wondering of there's a way to deploy your script on it instead of Heroku? If so, do you know how?

2- Is Heroku being used to download from GDrive and upload to Stremio, or is it only being used to fetch the results and push the GDrive links?

I'm assuming it's downloading and uploading, hence why I want to deploy on my own device to get faster speeds... If it's only fetching links, then Heroku is more than enough I guess and I won't need my RPi 😅

BTW, when can we expect the Android update that allows the addon to run without a proxy?

Heroku Alternative

Heroku does not provide free tiers anymore. Do we have alternative to Heroku, and how to deploy it? Thanks.

Please update Heroku part

I was unable to connect heroku with it .../manifest.json is not working for me even after leaving the cf proxy blank

 Application error

An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail 
```.
cloud worker is okay =  200 Online!. Please update this

How to configure this!?

I understand this repo is very much in its infancy, but I think this part is an essential part of this.
How am I supposed to config this add-on to scan my given folders!
Screenshot_2021-05-08-01-40-25-12_4d38fce200f96aeac5e860e739312e76

I'm not sure if Libdrive's config would exactly be working with it
And if it would work please tell me or document it so that we can atleast test the thing.
Thank you for reading through this.

Telegram Bot using server api

It would be nice to see to provide a bot interface using this plugin server api. we would be play stuff in any external player such as VLC, mxplayer etc.
Perhaps a web-ui also?

Question: services other than gdrive

Since rclone is being used, can we use it to search something else like Mega? will changing type and the values we pass in cf_proxy.js with rclone config file be enough?

Addon doesn't work with latest Stremio Android TV version

Hi again, ssnjr2002!

I hope you did well in your academics.

If you're not informed, Stremio just released an Android TV version of the app and it looks really great.

However, the gdrive addon is not returning any results in the app for some reason, I can see in the logs that it does find the links and tries to send them back to the Android TV app but nothing shows up in the app.

10.1.52.7 - - [10/Aug/2022:07:40:27 +0000] "GET /stream/movie/tt5113044.json HTTP/1.1" 200 58784 "-" "-"

Apparently, it doesn't recognize the Android TV client

Use streaming versions

Thank you for working on this project.

I would like to know if the addon is also capable of intercepting the streaming variants that Google creates for each video on Drive. Encoding would no longer be necessary and it saves resources.

Some files not showing up in results

Hi, ssnjr2002,

Once again, thank you so much for the amazing addon; it's a dream come true.

While browsing Iron Man 3 (2013), I noticed that some REMUX-1080p files are not showing up in results, only one of them showed up for some reason. (More REMUX-2160p files showed up, however.)

a) REMUX-1080p File that did show up:
1- Iron Man 3 (2013) 1080p Bluray REMUX x264 AVC [Hindi DDP5.1 ~ 640Kbps + English DTS-HDMA 7.1] Esub ~ FraMESToR.mkv

b) REMUX-1080p Files that did not show up:
1- Iron.Man.3.2013.BluRay.1080p.DTS-HD.MA.7.1.AVC.REMUX-FraMeSToR.mkv
2- Iron.Man.3.2013.CEE.REPACK.BluRay.Remux.1080p.AVC.DTS-HD.MA.7.1-HiFi.mkv
3- iron.man.3.2013.1080p.bluray.REMUX.dts-hd.ma.7.1-publichd (Hi10p reencode).mkv

c) REMUX-2160p files that did show up:
1- Iron Man 3 (2013) 2160p 4K UHD HDR10 Bluray REMUX x265 HEVC [Hindi DDP5.1 ~ 640Kbps + English DTS-HDMA 7.1] Esub ~ FGT2.mkv
2- Iron.Man.3.2013.UHD.2160p.BluRay.DTS-HDMA.7.1.HEVC.REMUX-FraMeSToR.mkv
3- Iron Man 3 2013 Remux-2160p.mkv

d) REMUX-2160p files that did not show up:
1- Iron.Man.3.2013.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.7.1-FGT.mkv
2- Iron.Man.3.2013.UHD.BluRay.2160p.TrueHD.Atmos.7.1.HEVC.REMUX-FraMeSToR.mkv
3- Iron.Man.3.2013.UHD.BluRay.2160p.DTS-HD.MA.7.1.HEVC.REMUX-FraMeSToR-4P.mkv
4- Iron.Man.3.2013.2160p.US.BluRay.REMUX.HEVC.DTS-HD.MA.TrueHD.7.1.Atmos-FGT.mkv
5- Iron.Man.3.2013.2160p.BluRay.REMUX.HEVC.DTS-HD.MA.7.1-FGT.mkv

c2, d2, and d3 are the same file, but only c2 showed up... The only difference I can see is that c2 has the resolution in its name before the type, while the other two have the type after "UHD" and before "2160p".

Of course, it is not a big deal, but I just wanted to let you know of the issue... Maybe you could find a solution 👍

P.S.: They've finally updated the Android app, it can now stream without a proxy :)

Anime Kitsu gives 404 error in the log

If we try to stream any anime from anime Kitsu addon no results pops for Gdrive

LOGS:
2021-10-10T06:34:34.423500+00:00 heroku[router]: at=info method=GET path="/stream/series/tt0388629%3A3%3A1.json" host=XXXXX request_id=eb0fe71f-0ae0-430c-8f96-69be4328ac91 fwd="XXXXX" dyno=web.1 connect=0ms service=2115ms status=200 bytes=1085 protocol=https
2021-10-10T06:36:55.284501+00:00 heroku[router]: at=info method=GET path="/stream/series/kitsu%3A12%3A1.json" host=XXXXXXX request_id=bd03776f-99cb-4b46-ad3d-2ace496f1fdd fwd="XXXXXX" dyno=web.1 connect=0ms service=2ms status=404 bytes=393 protocol=https
2021-10-10T06:36:55.284687+00:00 app[web.1]: 10.1.27.121 - - [10/Oct/2021:06:36:55 +0000] "GET /stream/series/kitsu%3A12%3A1.json HTTP/1.1" 404 232 "https://app.strem.io/shell-v4.4/" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.15.2 Chrome/XXXXXX Safari/537.36 StremioShell/4.4.142"
2021-10-10T06:37:45.934948+00:00 heroku[router]: at=info method=GET path="/stream/series/kitsu%3A42765%3A1.json" host=XXXXXXXX request_id=69924526-2964-4f22-a9ff-d95b2d499f87 fwd="XXXXXXX" dyno=web.1 connect=0ms service=1ms status=404 bytes=393 protocol=https
2021-10-10T06:37:45.935078+00:00 app[web.1]: 10.1.27.121 - - [10/Oct/2021:06:37:45 +0000] "GET /stream/series/kitsu%3A42765%3A1.json HTTP/1.1" 404 232 "https://app.strem.io/shell-v4.4/" "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.15.2 Chrome/XXXXXX Safari/537.36 StremioShell/4.4.142"

Error: 400

It's giving error: 400 on the google login page.

Please add this new feature.

Hey could you please add a new feature for the search to also look into folders?
Like I have a folder which has all the mkv files but it doesn't look into those folders.
I'm using a shared drive btw.

Sorting issue when there's a text before the movie's name

Hi again, ssnjr2002,

I noticed that if there's a text before a movie's name, then it'll get pushed down like shown in the screenshot below.
It goes like this: 2160p > 1080p > 720p > UnknownRes > 2160pWithTextBeofreMovie'sTitle > 1080pWithTextBeofreMovie'sTitle and so on...

Not a big deal obviously, but still wanted to let you know.
This is with the latest update btw.

image

File name not passed to other players

Hi,

Whenever I play anything on other players, the addon passes the file's name as "load" instead of the actual name, always.
I'm running the latest update of your code and Stremio, and I'm using a proxy... This issue is on both Android and Windows.

Thank you for everything :)

Titles with dots or apostrophes not showing up

Long time no see, ssnjr2002
I hope you're doing well

I noticed that the addon doesn't show titles that have apostrophes or dots, like "Ron's Gone Wild (2021)" and "What If...? (2021)"

a) Ron's Gone Wild (2021)
1- Rons.Gone.Wrong.2021.2160p.UHD.BluRay.REMUX.HDR.HEVC.Atmos-PiRaTeS.mkv
2- [MF] Rons.Gone.Wrong.2021.720p.BluRay.x265.10Bit-Pahe.mkv
3- Ron's.Gone.Wrong.2021.1080p.DSNP.ENG.WEB-DL.DDP5.1.HEVC.x265-Archie.mkv
4- Ron's Gone Wrong (2021) (2160p BluRay x265 10bit HDR Tigole).mkv
None of these titles show up

b) What If... ? (2021)
1- What If... (2021) - S01E01 - What If… Captain Cart… The First Avenger (1080p WEB-DL x265 Silence).mkv
2- What If…! - S01E01 - What If… Captain Carter Were The First Avenger WEBDL-1080p Proper.mkv
3- What.If.S01E01.iTA.ENG.HDR.2160p.WEB.HEVC.DDP5.1.h264-DENiED.mkv
4- What.If.S01E01.Captain.Carter.Were.The.First.Avenger.2160p.10bit.DSNP.WEB-DL.DDP5.1.HEVC-Vyndros.mkv
Only b1 and b2 show up.

I tried to solve this issue using the little experience I have with python, this is what I did to meta.py:
https://github.com/theghost970/stremio-gdrive/blob/e7c8abd900f1ee4069cad54bbdb6cd73395f3a31/sgd/meta.py#L69-L77

However, this solution is not perfect:

  • With this solution, it is able to show a1 and a2, but it's unable to show a3 and a4.
  • It is able to show everything in section b, but it introduced a new problem: Irrelevant results are showing up in case of "removing dots", those titles are:

1- The Secrets She Keeps - S01E01 - Episode 1 WEBDL-1080p.mkv
2- Murder at the Cottage - The Search for Justice for Sophie - S01E01 - Episode 1 WEBDL-1080p.mkv
3- The Serpent (2021) - S01E01 - Episode 1 (1080p AMZN WEB-DL x265 Ghost).mkv
4- The Serpent - S01E01 - Episode 1 WEBDL-1080p.mkv

It is not a big issue tbh, just wanted to let you know in case you were free :)

Having trouble with buffering

Followed the Method one but having hard time playing 1-5Gb files anything less than a gb plays fine but anything more than that keep on buffering what could be the issue ?

Unable to Fetch From Google Drive anymore.

2023-02-02T03:24:47.770 app[e7885b13] sin [info] [2023-02-02 03:24:47 +0000] [528] [ERROR] Error handling request

2023-02-02T03:24:47.770 app[e7885b13] sin [info] Traceback (most recent call last):

2023-02-02T03:24:47.770 app[e7885b13] sin [info] File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/sync.py", line 184, in handle_request

2023-02-02T03:24:47.770 app[e7885b13] sin [info] for item in respiter:

2023-02-02T03:24:47.770 app[e7885b13] sin [info] File "/app/.heroku/python/lib/python3.9/site-packages/werkzeug/wsgi.py", line 462, in __next__

2023-02-02T03:24:47.770 app[e7885b13] sin [info] return self._next()

2023-02-02T03:24:47.770 app[e7885b13] sin [info] File "/app/.heroku/python/lib/python3.9/site-packages/werkzeug/wrappers/response.py", line 49, in _iter_encoded

2023-02-02T03:24:47.770 app[e7885b13] sin [info] for item in iterable:

2023-02-02T03:24:47.770 app[e7885b13] sin [info] File "/app/sgd/routes.py", line 63, in get_streams

2023-02-02T03:24:47.770 app[e7885b13] sin [info] stream_meta = Meta(stream_type, stream_id)

2023-02-02T03:24:47.770 app[e7885b13] sin [info] File "/app/sgd/meta.py", line 120, in __init__

2023-02-02T03:24:47.770 app[e7885b13] sin [info] IMDb.__init__(self)

2023-02-02T03:24:47.770 app[e7885b13] sin [info] File "/app/sgd/meta.py", line 21, in __init__

2023-02-02T03:24:47.770 app[e7885b13] sin [info] if not self.get_meta_from_imdb_sg():

2023-02-02T03:24:47.770 app[e7885b13] sin [info] File "/app/sgd/meta.py", line 85, in get_meta_from_imdb_sg

2023-02-02T03:24:47.770 app[e7885b13] sin [info] self.set_meta(meta[0], year="y", name="l")

2023-02-02T03:24:47.770 app[e7885b13] sin [info] TypeError: set_meta() got an unexpected keyword argument 'name'

Not a programmer, need help when you have time please.

Addon doesn't work with latest Stremio Android TV version (v2)

Hi again, ssnjr2002!
Long time no see.
I hope you're doing well.

I updated to v1.5.8 of Stremio Android TV and the streams of this addon stopped working for some reason.
The streams do appear in the list, but when I click on one, it doesn't play. It switches to VLC and then gives an error message.
I had to rollback to v1.5.7 which works like a charm.

Is anyone else facing this issue or is it just me?

video error

im getting "playback error, please try again" after opening any video

Error 400: invalid_request

You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy for keeping apps secure.

You can let the app developer know that this app doesn't comply with one or more Google validation rules.

Request Details
The content in this section has been provided by the app developer. This content has not been reviewed or verified by Google.
If you’re the app developer, make sure that these request details comply with Google policies.

redirect_uri: urn:ietf:wg:oauth:2.0:oob

help

Excellent job. I need a catalog option which shows all my movies from google drive. Could you add it, please?

It would be great to list the gdrive folder names in the Type section.

SAVE_20210616_194156.jpg

Stremio crashing when using Cloudflare proxy

We meet again, ssnjr2002 😄

When I use the proxy and after ~15 mins, Stremio becomes heavy and stutters a lot, and then it crashes at last.
When this happens, my whole device becomes unresponsive until Stremio crashes and exits.

  • This happens on all my devices: Shield TV (2017) and Chromecast with Google TV.
  • The versions I tried: 1.4.5, 1.4.13, and 1.4.16.
  • The first 15 minutes (sometimes 30 minutes) play just fine, then the issue begins out of nowhere.
  • I tried all the HW Decoding settings (Auto, Disabled, Decoding, Full).
  • I have the cache set to 0. (But even other values don't help).
  • It's not an internet issue, as I'm able to play the same films without proxy without issues

Given the last point, I don't know if it's truly the addon's issue or Stremio's, but note that this doesn't happen with other DL addons such as 123Movies... So I really don't know what's the issue.

Edit: Forgot to mention that I tried large files and small files (30GB+ and ~5GB)
And all of this with Arabic subtitles from the official addon "opensubtitles"

Heroku Deployment Issue.

Item could not be created:
We couldn't deploy your app because the source code violates the Salesforce Acceptable Use and External-Facing Services Policy.

guess we will have to find other place to deploy this?

listing of animes with 001 doesnt work!

the drive just works fine with s01E01 type of content but when it comes to onepeice where al of them are listed as 001 002 003 the addon just neglects them

The torrentio works fine so something on the gdrive addon side maybe?

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.