├── .bin ├── pinger.py ├── setup.sh └── start.sh ├── Dockerfile ├── LICENSE ├── README.md ├── app.json ├── heroku.yml └── wrangler.toml /.bin/pinger.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | 4 | import requests 5 | 6 | url = os.environ.get("PINGER") 7 | if url: 8 | if url.endswith("/"): 9 | url = url[:-1] 10 | while True: 11 | time.sleep(int(os.environ.get("PINGER_INTERVAL", 900))) 12 | requests.get("%s/api/v1/ping" % (url)) 13 | -------------------------------------------------------------------------------- /.bin/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /usr/src/app/.bin 4 | 5 | mkdir ./dev 6 | cd ./dev 7 | mkdir ./tmp 8 | cd ./tmp 9 | git clone "https://github.com/libDrive/server.git" --depth 1 server 10 | git clone "https://github.com/libDrive/web.git" --depth 1 web 11 | mkdir ./libDrive.Server 12 | mkdir ./libDrive.Server/build 13 | mkdir ./libDrive.Server/src 14 | mkdir ./libDrive.Server/templates 15 | cd ./web 16 | yarn install 17 | yarn run build 18 | mv ./build/* ../libDrive.Server/build 19 | cd ../server 20 | mv main.py requirements.txt ../libDrive.Server 21 | mv ./src/* ../libDrive.Server/src 22 | mv ./templates/* ../libDrive.Server/templates 23 | cd .. 24 | cp ../../../README.md ../../../LICENSE ./libDrive.Server 25 | cd libDrive.Server 26 | mv ./* ../.. 27 | cd ../../.. 28 | -------------------------------------------------------------------------------- /.bin/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /usr/src/app/.bin 4 | 5 | if [ "${LIBDRIVE_VERSION}" != "dev" ]; then 6 | if [ ! -z "${LIBDRIVE_VERSION}" ]; then 7 | if [ "${LIBDRIVE_VERSION}" = "latest" ]; then 8 | VER="latest" 9 | else 10 | VER="tags/${LIBDRIVE_VERSION}" 11 | fi 12 | else 13 | VER="latest" 14 | fi 15 | 16 | if [ ! -z "${LIBDRIVE_REPOSITRY}" ]; then 17 | REPO=${LIBDRIVE_REPOSITRY} 18 | else 19 | REPO="libDrive/libDrive" 20 | fi 21 | 22 | curl -L -s $(curl -s "https://api.github.com/repos/${REPO}/releases/${VER}" | grep -Po '"browser_download_url": "\K.*?(?=")') | tar xf - -C . 23 | 24 | pip3 install -r requirements.txt -q --no-cache-dir 25 | else 26 | cd ./dev 27 | fi 28 | 29 | pip3 install -r requirements.txt -q --no-cache-dir 30 | if [ "${LOCAL_CLOUDFLARE}" = "True" ] | [ "$LOCAL_CLOUDFLARE" = "true" ]; then 31 | if [ ! -z "${PINGER}" ]; then 32 | gunicorn main:app & 33 | python3 /usr/src/app/.bin/pinger.py & 34 | wrangler dev --port 31146 35 | else 36 | gunicorn main:app & 37 | wrangler dev --port 31146 38 | fi 39 | else 40 | if [ ! -z "${PINGER}" ]; then 41 | gunicorn main:app & 42 | python3 /usr/src/app/.bin/pinger.py 43 | else 44 | gunicorn main:app 45 | fi 46 | fi 47 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | WORKDIR /usr/src/app 4 | 5 | ENV TZ UTC 6 | 7 | RUN chmod 777 /usr/src/app 8 | 9 | RUN apt-get update -y && \ 10 | apt-get install -y --no-install-recommends python3.9 && \ 11 | apt-get install -y --no-install-recommends python3.9-dev && \ 12 | apt-get install -y --no-install-recommends python3-pip && \ 13 | apt-get install -y curl && \ 14 | apt-get install -y git && \ 15 | apt-get install -y gnupg 16 | RUN curl -sL https://deb.nodesource.com/setup_16.x | bash - 17 | RUN apt-get -y install nodejs 18 | RUN npm install --global yarn 19 | RUN npm install --global @cloudflare/wrangler 20 | 21 | RUN curl -O https://raw.githubusercontent.com/libDrive/server/main/requirements.txt && \ 22 | pip3 install -r requirements.txt --no-cache-dir 23 | 24 | ENV PATH="/usr/src/app/.local/bin:${PATH}" 25 | 26 | COPY . . 27 | 28 | RUN chmod +x ./.bin/setup.sh ./.bin/start.sh 29 | RUN ./.bin/setup.sh 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 libDrive 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 |

3 | 4 |

5 |
6 |

7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 |

15 | 16 | 17 | 18 |

19 |

20 | 21 | 22 | 23 |

24 | 25 | # What is this repo? 26 | 27 | libDrive is a Google Drive media library manager and indexer, similar to Plex, that organizes Google Drive media to offer an intuitive and user-friendly experience. 28 | 29 | I decided to create this project to, of course, organize my Google Drive library, but also develop my coding skills, and learn JavaScript in the process. 30 | 31 | This repository () stores the source code for the [Heroku](https://heroku.com) deployment of libDrive. 32 | 33 | ## Source code 34 | 35 | - [libDrive/libDrive](https://github.com/libDrive/libDrive) 36 | - [libDrive/server](https://github.com/libDrive/server) 37 | - [libDrive/web](https://github.com/libDrive/web) 38 | - [libDrive/cloudflare](https://github.com/libDrive/cloudflare) 39 | - [libDrive/heroku](https://github.com/libDrive/heroku) 40 | - [libDrive/config](https://github.com/libDrive/config) 41 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libDrive", 3 | "description": "libDrive is a Google Drive media library manager and indexer, similar to Plex, that organizes Google Drive media to offer an intuitive and user-friendly experience.", 4 | "keywords": [ 5 | "heroku", 6 | "movies", 7 | "plex", 8 | "google-drive", 9 | "tv", 10 | "indexing", 11 | "indexer", 12 | "drive", 13 | "index", 14 | "gdrive", 15 | "cloudflare-workers", 16 | "goindex", 17 | "gindex", 18 | "libdrive" 19 | ], 20 | "website": "https://github.com/libDrive/libDrive", 21 | "repository": "https://github.com/libDrive/libDrive", 22 | "logo": "https://avatars2.githubusercontent.com/u/75073550?v=4", 23 | "success_url": "/", 24 | "env": { 25 | "LIBDRIVE_CLOUD": { 26 | "description": "The ID of any empty Google Drive folder. This folder will be used to store the config and metadata generated by libDrive", 27 | "value": "", 28 | "required": false 29 | }, 30 | "LIBDRIVE_CONFIG": { 31 | "description": "Create this through the config generator: https://config.libdrive.tk. Make sure to read the meaning of each variable on the wiki: https://github.com/libDrive/libDrive/wiki/Config", 32 | "value": "{\r\n \"access_token\": \"\",\r\n \"account_list\": [],\r\n \"arcio\": \"dev\",\r\n \"auth\": true,\r\n \"build_interval\": 120,\r\n \"build_type\": \"hybrid\",\r\n \"category_list\": [],\r\n \"client_id\": \"\",\r\n \"client_secret\": \"\",\r\n \"cloudflare\": \"\",\r\n \"refresh_token\": \"\",\r\n \"secret_key\": \"\",\r\n \"tmdb_api_key\": \"\",\r\n \"token_expiry\": \"\",\r\n \"prefer_mkv\": false,\r\n \"prefer_mp4\": false,\r\n \"transcoded\": false,\r\n \"service_accounts\": [],\r\n \"subtitles\": false,\r\n \"signup\": false,\r\n \"ui_config\": {}\r\n}", 33 | "required": true 34 | }, 35 | "LIBDRIVE_VERSION": { 36 | "description": "The version to deploy (e.g. v1.3.10). 'latest' and 'dev' are also accepted, 'latest' automatically updates libDrive on each restart. 'dev' builds libDrive using the latest commit, this will only be built once, on the first deploy", 37 | "value": "latest", 38 | "required": false 39 | }, 40 | "PINGER": { 41 | "description": "The pinger pings your app every 15 minutes to prevent it from sleeping. Input the URL of your app (e.g. https://APP_NAME.herokuapp.com). Leave empty if you don't want to use the pinger", 42 | "value": "https://APP_NAME.herokuapp.com", 43 | "required": false 44 | }, 45 | "PINGER_INTERVAL": { 46 | "description": "How often, in seconds, the pinger will be used", 47 | "value": "900", 48 | "required": false 49 | }, 50 | "WEB_CONCURRENCY": { 51 | "description": "Don't change this, leave the value as 1", 52 | "value": "1", 53 | "required": true 54 | } 55 | }, 56 | "stack": "container" 57 | } 58 | -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | web: Dockerfile 4 | run: 5 | web: ./.bin/start.sh 6 | -------------------------------------------------------------------------------- /wrangler.toml: -------------------------------------------------------------------------------- 1 | name = "libdrive" 2 | type = "javascript" 3 | account_id = "libdrive" 4 | workers_dev = true 5 | route = "" 6 | zone_id = "" 7 | --------------------------------------------------------------------------------