├── .dockerignore ├── .github └── workflows │ ├── docker-image.yml │ ├── docker-publish.yml │ └── docs-deploy.yml ├── .gitignore ├── .prettierrc.json ├── Dockerfile ├── LICENSE ├── README.md ├── app.vue ├── assets ├── app.css ├── latte.ts └── macchiato.ts ├── components ├── AppToast.vue ├── BackgroundImages.vue ├── DiskSpaceCard.vue ├── ErrorAlert.vue ├── Media │ └── Grid.vue ├── Plex │ ├── LoginCard.vue │ └── Settings.vue ├── Remove │ └── Grid.vue ├── ServarrSettingsForm.vue ├── SetupForm.vue ├── User │ ├── List.vue │ ├── Menu.vue │ └── Votes.vue └── Vote │ └── Results.vue ├── compose.yaml ├── config ├── .gitkeep └── db │ └── .gitkeep ├── docs ├── .vitepress │ ├── config.ts │ └── theme │ │ ├── index.ts │ │ └── style.css ├── index.md ├── install.md ├── settings │ └── plex.md └── support │ └── upgrade.md ├── drizzle.config.ts ├── eslint.config.mjs ├── i18n └── locales │ ├── en.json │ └── fr.json ├── layouts ├── default.vue └── empty.vue ├── middleware └── setup.ts ├── nuxt.config.ts ├── package-lock.json ├── package.json ├── pages ├── index.vue ├── login │ ├── index.vue │ └── plex │ │ └── loading.vue ├── movies.vue ├── profile.vue ├── remove.vue ├── settings.vue ├── setup.vue ├── shows.vue ├── user │ └── votes.vue └── users.vue ├── public ├── apple-touch-icon-180x180.png ├── favicon.ico ├── images │ ├── party.webp │ ├── plex.svg │ ├── radarr.svg │ └── sonarr.svg ├── logo.svg ├── maskable-icon-512x512.png ├── preview.webp ├── pwa-192x192.png ├── pwa-512x512.png ├── pwa-64x64.png └── robots.txt ├── server ├── api │ ├── auth │ │ ├── login.post.ts │ │ └── user.get.ts │ ├── imdb │ │ └── backdrops │ │ │ └── index.get.ts │ ├── plex │ │ ├── setup │ │ │ └── index.post.ts │ │ ├── token │ │ │ └── index.post.ts │ │ └── users │ │ │ └── index.get.ts │ ├── proxy │ │ ├── radarr │ │ │ └── [...] │ │ │ │ ├── index.delete.ts │ │ │ │ └── index.get.ts │ │ └── sonarr │ │ │ └── [...] │ │ │ ├── index.delete.ts │ │ │ ├── index.get.ts │ │ │ └── index.ts │ ├── settings │ │ ├── [...servarr] │ │ │ ├── index.get.ts │ │ │ └── index.post.ts │ │ ├── index.get.ts │ │ ├── index.post.ts │ │ └── plex │ │ │ ├── index.get.ts │ │ │ └── index.post.ts │ ├── users │ │ ├── [...id] │ │ │ ├── index.get.ts │ │ │ └── index.put.ts │ │ ├── index.get.ts │ │ └── index.post.ts │ └── votes │ │ ├── index.get.ts │ │ ├── index.post.ts │ │ ├── media │ │ └── [...mediaId] │ │ │ └── index.delete.ts │ │ ├── results │ │ ├── index.delete.ts │ │ └── index.get.ts │ │ └── user │ │ └── [...userId] │ │ └── index.get.ts ├── database │ ├── index.ts │ ├── migrations │ │ ├── 0000_init.sql │ │ └── meta │ │ │ ├── 0000_snapshot.json │ │ │ └── _journal.json │ └── schema.ts ├── plugins │ └── dbInit.ts ├── repository │ └── settingRepository.ts └── tsconfig.json ├── tsconfig.json ├── types └── global.d.ts └── utils └── plex.ts /.dockerignore: -------------------------------------------------------------------------------- 1 | # Nuxt dev/build outputs 2 | .output 3 | .data 4 | .nuxt 5 | .nitro 6 | .cache 7 | dist 8 | docs 9 | 10 | # Node dependencies 11 | node_modules 12 | 13 | # Logs 14 | logs 15 | *.log 16 | 17 | # Misc 18 | .DS_Store 19 | .fleet 20 | .idea 21 | .git 22 | .github 23 | 24 | .gitignore 25 | README.md 26 | -------------------------------------------------------------------------------- /.github/workflows/docker-image.yml: -------------------------------------------------------------------------------- 1 | name: Docker Image CI 2 | 3 | on: 4 | push: 5 | branches: ["main"] 6 | pull_request: 7 | branches: ["main"] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Build the Docker image 16 | run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) 17 | -------------------------------------------------------------------------------- /.github/workflows/docker-publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish Docker image 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | push_to_registries: 9 | name: Push Docker image to multiple registries 10 | runs-on: ubuntu-latest 11 | permissions: 12 | packages: write 13 | contents: read 14 | attestations: write 15 | id-token: write 16 | steps: 17 | - name: Check out the repo 18 | uses: actions/checkout@v4 19 | 20 | - name: Log in to Docker Hub 21 | uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a 22 | with: 23 | username: ${{ secrets.DOCKER_USERNAME }} 24 | password: ${{ secrets.DOCKER_PASSWORD }} 25 | 26 | - name: Log in to the Container registry 27 | uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 28 | with: 29 | registry: ghcr.io 30 | username: ${{ github.actor }} 31 | password: ${{ secrets.GITHUB_TOKEN }} 32 | 33 | - name: Extract metadata (tags, labels) for Docker 34 | id: meta 35 | uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 36 | with: 37 | images: | 38 | tphilippot/removarr 39 | ghcr.io/${{ github.repository }} 40 | 41 | - name: Build and push Docker images 42 | id: push 43 | uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 44 | with: 45 | context: . 46 | push: true 47 | tags: ${{ steps.meta.outputs.tags }} 48 | labels: ${{ steps.meta.outputs.labels }} 49 | 50 | - name: Generate artifact attestation 51 | uses: actions/attest-build-provenance@v2 52 | with: 53 | subject-name: ghcr.io/${{ github.repository }} 54 | subject-digest: ${{ steps.push.outputs.digest }} 55 | push-to-registry: true 56 | -------------------------------------------------------------------------------- /.github/workflows/docs-deploy.yml: -------------------------------------------------------------------------------- 1 | name: docs-deploy.yml 2 | on: 3 | push: 4 | branches: [main] 5 | workflow_dispatch: 6 | 7 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 8 | permissions: 9 | contents: read 10 | pages: write 11 | id-token: write 12 | 13 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. 14 | # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. 15 | concurrency: 16 | group: pages 17 | cancel-in-progress: false 18 | 19 | jobs: 20 | # Build job 21 | build: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: Checkout 25 | uses: actions/checkout@v4 26 | with: 27 | fetch-depth: 0 # Not needed if lastUpdated is not enabled 28 | - name: Setup Node 29 | uses: actions/setup-node@v4 30 | with: 31 | node-version: 22 32 | cache: npm # or pnpm / yarn 33 | - name: Setup Pages 34 | uses: actions/configure-pages@v4 35 | - name: Install dependencies 36 | run: npm ci 37 | - name: Build with VitePress 38 | run: npm run docs:build 39 | - name: Upload artifact 40 | uses: actions/upload-pages-artifact@v3 41 | with: 42 | path: docs/.vitepress/dist 43 | 44 | # Deployment job 45 | deploy: 46 | environment: 47 | name: github-pages 48 | url: ${{ steps.deployment.outputs.page_url }} 49 | needs: build 50 | runs-on: ubuntu-latest 51 | name: Deploy 52 | steps: 53 | - name: Deploy to GitHub Pages 54 | id: deployment 55 | uses: actions/deploy-pages@v4 56 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Nuxt dev/build outputs 2 | .output 3 | .data 4 | .nuxt 5 | .nitro 6 | .cache 7 | dist 8 | 9 | # Node dependencies 10 | node_modules 11 | .eslintcache 12 | 13 | # Logs 14 | logs 15 | *.log 16 | 17 | # Misc 18 | .DS_Store 19 | .fleet 20 | .idea 21 | 22 | # Local env files 23 | .env 24 | .env.* 25 | !.env.example 26 | 27 | # database 28 | config/db/*.sqlite3* 29 | config/settings.json 30 | 31 | # docs 32 | docs/.vitepress/cache 33 | docs/.vitepress/dist 34 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:22.15.0-alpine AS build 2 | 3 | LABEL authors="Thomas Philippot" 4 | 5 | ARG PORT=3000 6 | 7 | WORKDIR /app 8 | 9 | COPY package.json package-lock.json ./ 10 | 11 | RUN npm install 12 | 13 | COPY . ./ 14 | 15 | RUN npm run build 16 | 17 | FROM node:22.15.0-alpine AS prod 18 | 19 | WORKDIR /app 20 | 21 | ENV HOST=0.0.0.0 22 | ENV PORT=$PORT 23 | ENV NODE_ENV=production 24 | 25 | COPY --from=build /app/.output ./.output 26 | COPY --from=build /app/config ./config 27 | COPY --from=build /app/server ./server 28 | 29 | EXPOSE 3000 30 | 31 | CMD ["node", ".output/server/index.mjs"] 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Removarr 2 | 3 | Removarr allow plex users to vote for media to be deleted on shared plex library 4 | 5 | ## Features 6 | 7 | - Plex integration : 8 | - User authentication 9 | - User access 10 | - Enable/Disable libraries 11 | - Sonarr integration : list TV Shows from the enabled plex libraries 12 | - Radarr integration : list Movies from the enabled plex libraries 13 | - Display storage information to users 14 | - Mobile support with PWA. 15 | 16 | ## Preview 17 | 18 | ![preview](/public/preview.webp) 19 | 20 | ## Installation 21 | 22 | Define the removarr service in your `compose.yaml` as follows: 23 | 24 | > change `/path/to/config` with your custom directory path 25 | 26 | ```yaml 27 | services: 28 | removarr: 29 | container_name: removarr 30 | image: tphilippot/removarr:latest 31 | ports: 32 | - 3000:3000 33 | volumes: 34 | - /path/to/config:/app/config 35 | ``` 36 | 37 | The starts the service 38 | 39 | `docker compose up -d` 40 | 41 | ## Development Server 42 | 43 | Start the development server on `http://localhost:3000`: 44 | 45 | ```bash 46 | # npm 47 | npm install 48 | npm run dev 49 | 50 | # pnpm 51 | pnpm install 52 | pnpm dev 53 | 54 | # yarn 55 | yarn install 56 | yarn dev 57 | 58 | # bun 59 | bun install 60 | bun run dev 61 | ``` 62 | 63 | Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. 64 | -------------------------------------------------------------------------------- /app.vue: -------------------------------------------------------------------------------- 1 | 9 | -------------------------------------------------------------------------------- /assets/app.css: -------------------------------------------------------------------------------- 1 | @import "tailwindcss"; 2 | @plugin "daisyui" { 3 | themes: false; 4 | exclude: rootscrollgutter; 5 | } 6 | 7 | @plugin "@tailwindcss/typography"; 8 | @plugin "./latte.ts"; 9 | @plugin "./macchiato.ts"; 10 | 11 | ul.cards-vertical, 12 | ul.cards-horizontal { 13 | @apply grid gap-4; 14 | } 15 | 16 | ul.cards-vertical { 17 | grid-template-columns: repeat(auto-fill, minmax(9.375rem, 1fr)); 18 | } 19 | 20 | .nuxt-loading-indicator { 21 | @apply bg-primary; 22 | } 23 | 24 | .menu .router-link-exact-active { 25 | @apply bg-primary text-base-300 font-semibold; 26 | } 27 | 28 | .dock .router-link-exact-active { 29 | @apply dock-active; 30 | } 31 | 32 | #nt-container { 33 | @apply toast z-50; 34 | top: calc(0.25rem * 4); 35 | bottom: auto; 36 | @variant sm { 37 | top: auto; 38 | bottom: calc(0.25rem * 4); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /assets/latte.ts: -------------------------------------------------------------------------------- 1 | import { createCatppuccinPlugin } from "@catppuccin/daisyui"; 2 | 3 | export default createCatppuccinPlugin( 4 | "latte", 5 | {}, 6 | { 7 | default: true, 8 | }, 9 | ); 10 | -------------------------------------------------------------------------------- /assets/macchiato.ts: -------------------------------------------------------------------------------- 1 | import { createCatppuccinPlugin } from "@catppuccin/daisyui"; 2 | 3 | export default createCatppuccinPlugin( 4 | "macchiato", 5 | { 6 | primary: "lavender", 7 | "primary-content": "mantle", 8 | secondary: "surface0", 9 | "secondary-content": "text", 10 | accent: "rosewater", 11 | "accent-content": "mantle", 12 | neutral: "overlay1", 13 | "neutral-content": "mantle", 14 | }, 15 | { prefersdark: true }, 16 | ); 17 | -------------------------------------------------------------------------------- /components/AppToast.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /components/BackgroundImages.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /components/DiskSpaceCard.vue: -------------------------------------------------------------------------------- 1 | 36 | 37 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /components/ErrorAlert.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /components/Media/Grid.vue: -------------------------------------------------------------------------------- 1 | 131 | 132 | 264 | 265 | 266 | -------------------------------------------------------------------------------- /components/Plex/LoginCard.vue: -------------------------------------------------------------------------------- 1 | 23 | 24 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /components/Plex/Settings.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /components/Remove/Grid.vue: -------------------------------------------------------------------------------- 1 | 104 | 105 | 274 | 275 | 276 | -------------------------------------------------------------------------------- /components/ServarrSettingsForm.vue: -------------------------------------------------------------------------------- 1 | 53 | 54 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /components/SetupForm.vue: -------------------------------------------------------------------------------- 1 | 71 | 72 | 302 | 303 | 304 | -------------------------------------------------------------------------------- /components/User/List.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /components/User/Menu.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /components/User/Votes.vue: -------------------------------------------------------------------------------- 1 | 30 | 31 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /components/Vote/Results.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /compose.yaml: -------------------------------------------------------------------------------- 1 | services: 2 | removarr: 3 | container_name: removarr 4 | build: 5 | context: . 6 | ports: 7 | - 3000:3000 8 | volumes: 9 | - ./config:/app/config 10 | -------------------------------------------------------------------------------- /config/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/config/.gitkeep -------------------------------------------------------------------------------- /config/db/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/config/db/.gitkeep -------------------------------------------------------------------------------- /docs/.vitepress/config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vitepress"; 2 | 3 | // https://vitepress.dev/reference/site-config 4 | export default defineConfig({ 5 | title: "Removarr", 6 | base: "/removarr/", 7 | description: "Media deletion tool for shared plex library", 8 | themeConfig: { 9 | // https://vitepress.dev/reference/default-theme-config 10 | nav: [ 11 | { text: "Home", link: "/" }, 12 | { text: "Installation", link: "/install" }, 13 | ], 14 | 15 | sidebar: [ 16 | { 17 | text: "Getting Started", 18 | items: [{ text: "Installation", link: "/install" }], 19 | }, 20 | { 21 | text: "Settings", 22 | items: [{ text: "Plex", link: "/settings/plex" }], 23 | }, 24 | { 25 | text: "Support", 26 | items: [{ text: "Version 2 upgrade", link: "/support/upgrade" }], 27 | }, 28 | ], 29 | 30 | socialLinks: [ 31 | { icon: "github", link: "https://github.com/thomas-philippot/removarr" }, 32 | ], 33 | }, 34 | }); 35 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/index.ts: -------------------------------------------------------------------------------- 1 | // https://vitepress.dev/guide/custom-theme 2 | import { h } from "vue"; 3 | import type { Theme } from "vitepress"; 4 | import DefaultTheme from "vitepress/theme"; 5 | import "./style.css"; 6 | 7 | export default { 8 | extends: DefaultTheme, 9 | Layout: () => { 10 | return h(DefaultTheme.Layout, null, { 11 | // https://vitepress.dev/guide/extending-default-theme#layout-slots 12 | }); 13 | }, 14 | enhanceApp() { 15 | // ... 16 | }, 17 | } satisfies Theme; 18 | -------------------------------------------------------------------------------- /docs/.vitepress/theme/style.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Customize default theme styling by overriding CSS variables: 3 | * https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css 4 | */ 5 | 6 | /** 7 | * Colors 8 | * 9 | * Each colors have exact same color scale system with 3 levels of solid 10 | * colors with different brightness, and 1 soft color. 11 | * 12 | * - `XXX-1`: The most solid color used mainly for colored text. It must 13 | * satisfy the contrast ratio against when used on top of `XXX-soft`. 14 | * 15 | * - `XXX-2`: The color used mainly for hover state of the button. 16 | * 17 | * - `XXX-3`: The color for solid background, such as bg color of the button. 18 | * It must satisfy the contrast ratio with pure white (#ffffff) text on 19 | * top of it. 20 | * 21 | * - `XXX-soft`: The color used for subtle background such as custom container 22 | * or badges. It must satisfy the contrast ratio when putting `XXX-1` colors 23 | * on top of it. 24 | * 25 | * The soft color must be semi transparent alpha channel. This is crucial 26 | * because it allows adding multiple "soft" colors on top of each other 27 | * to create a accent, such as when having inline code block inside 28 | * custom containers. 29 | * 30 | * - `default`: The color used purely for subtle indication without any 31 | * special meanings attached to it such as bg color for menu hover state. 32 | * 33 | * - `brand`: Used for primary brand colors, such as link text, button with 34 | * brand theme, etc. 35 | * 36 | * - `tip`: Used to indicate useful information. The default theme uses the 37 | * brand color for this by default. 38 | * 39 | * - `warning`: Used to indicate warning to the users. Used in custom 40 | * container, badges, etc. 41 | * 42 | * - `danger`: Used to show error, or dangerous message to the users. Used 43 | * in custom container, badges, etc. 44 | * -------------------------------------------------------------------------- */ 45 | 46 | :root { 47 | --vp-c-default-1: var(--vp-c-gray-1); 48 | --vp-c-default-2: var(--vp-c-gray-2); 49 | --vp-c-default-3: var(--vp-c-gray-3); 50 | --vp-c-default-soft: var(--vp-c-gray-soft); 51 | 52 | --vp-c-brand-1: var(--vp-c-indigo-1); 53 | --vp-c-brand-2: var(--vp-c-indigo-2); 54 | --vp-c-brand-3: var(--vp-c-indigo-3); 55 | --vp-c-brand-soft: var(--vp-c-indigo-soft); 56 | 57 | --vp-c-tip-1: var(--vp-c-brand-1); 58 | --vp-c-tip-2: var(--vp-c-brand-2); 59 | --vp-c-tip-3: var(--vp-c-brand-3); 60 | --vp-c-tip-soft: var(--vp-c-brand-soft); 61 | 62 | --vp-c-warning-1: var(--vp-c-yellow-1); 63 | --vp-c-warning-2: var(--vp-c-yellow-2); 64 | --vp-c-warning-3: var(--vp-c-yellow-3); 65 | --vp-c-warning-soft: var(--vp-c-yellow-soft); 66 | 67 | --vp-c-danger-1: var(--vp-c-red-1); 68 | --vp-c-danger-2: var(--vp-c-red-2); 69 | --vp-c-danger-3: var(--vp-c-red-3); 70 | --vp-c-danger-soft: var(--vp-c-red-soft); 71 | } 72 | 73 | /** 74 | * Component: Button 75 | * -------------------------------------------------------------------------- */ 76 | 77 | :root { 78 | --vp-button-brand-border: transparent; 79 | --vp-button-brand-text: var(--vp-c-white); 80 | --vp-button-brand-bg: var(--vp-c-brand-3); 81 | --vp-button-brand-hover-border: transparent; 82 | --vp-button-brand-hover-text: var(--vp-c-white); 83 | --vp-button-brand-hover-bg: var(--vp-c-brand-2); 84 | --vp-button-brand-active-border: transparent; 85 | --vp-button-brand-active-text: var(--vp-c-white); 86 | --vp-button-brand-active-bg: var(--vp-c-brand-1); 87 | } 88 | 89 | /** 90 | * Component: Home 91 | * -------------------------------------------------------------------------- */ 92 | 93 | :root { 94 | --vp-home-hero-name-color: transparent; 95 | --vp-home-hero-name-background: -webkit-linear-gradient( 96 | 120deg, 97 | #bd34fe 30%, 98 | #41d1ff 99 | ); 100 | 101 | --vp-home-hero-image-background-image: linear-gradient( 102 | -45deg, 103 | #bd34fe 50%, 104 | #47caff 50% 105 | ); 106 | --vp-home-hero-image-filter: blur(44px); 107 | } 108 | 109 | @media (min-width: 640px) { 110 | :root { 111 | --vp-home-hero-image-filter: blur(56px); 112 | } 113 | } 114 | 115 | @media (min-width: 960px) { 116 | :root { 117 | --vp-home-hero-image-filter: blur(68px); 118 | } 119 | } 120 | 121 | /** 122 | * Component: Custom Block 123 | * -------------------------------------------------------------------------- */ 124 | 125 | :root { 126 | --vp-custom-block-tip-border: transparent; 127 | --vp-custom-block-tip-text: var(--vp-c-text-1); 128 | --vp-custom-block-tip-bg: var(--vp-c-brand-soft); 129 | --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft); 130 | } 131 | 132 | /** 133 | * Component: Algolia 134 | * -------------------------------------------------------------------------- */ 135 | 136 | .DocSearch { 137 | --docsearch-primary-color: var(--vp-c-brand-1) !important; 138 | } 139 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | # https://vitepress.dev/reference/default-theme-home-page 3 | layout: home 4 | 5 | hero: 6 | name: "Removarr" 7 | text: "Media deletion tool for shared plex library" 8 | actions: 9 | - theme: brand 10 | text: Getting Started 11 | link: /install 12 | 13 | features: 14 | - title: Collaborative 15 | details: Users vote for the media to be deleted 16 | - title: Plex Integration 17 | details: Users authenticate with their plex account. 18 | - title: Radarr / Sonarr 19 | details: Display Radarr movies and Sonarr TV Shows 20 | --- 21 | -------------------------------------------------------------------------------- /docs/install.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | Define the removarr service in your `compose.yaml` as follows: 4 | 5 | > change `/path/to/config` with your custom directory path 6 | 7 | ```yaml 8 | services: 9 | removarr: 10 | container_name: removarr 11 | image: tphilippot/removarr:latest 12 | ports: 13 | - 3000:3000 14 | volumes: 15 | - /path/to/config:/app/config 16 | ``` 17 | 18 | The starts the service 19 | 20 | `docker compose up -d` 21 | -------------------------------------------------------------------------------- /docs/settings/plex.md: -------------------------------------------------------------------------------- 1 | # Plex 2 | 3 | You can filter libraries if you want to hide private libraries to users. 4 | 5 | Once enabled you can toggle the libraries you want to display. 6 | -------------------------------------------------------------------------------- /docs/support/upgrade.md: -------------------------------------------------------------------------------- 1 | # Version 2 upgrade 2 | 3 | Database changes were introduced in version 2, so you need to regenerate your database. 4 | 5 | ### Remove database and settings 6 | 7 | To remove the database and settings, run: 8 | 9 | ```bash 10 | rm path/to/config/db/db.sqlite3 11 | rm path/to/config/settings.json 12 | ``` 13 | 14 | > **Note:** change `/path/to/config` with your custom directory path 15 | 16 | This will remove the database and settings, so you will need to re-configure the application. 17 | -------------------------------------------------------------------------------- /drizzle.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "drizzle-kit"; 2 | 3 | const dbLocation = process.env.DATABASE_URL 4 | ? process.env.DATABASE_URL 5 | : "file:config/db/db.sqlite3"; 6 | 7 | export default defineConfig({ 8 | dialect: "sqlite", 9 | schema: "./server/database/schema.ts", 10 | out: "./server/database/migrations", 11 | dbCredentials: { 12 | url: dbLocation, 13 | }, 14 | }); 15 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | import withNuxt from "./.nuxt/eslint.config.mjs"; 3 | import eslintConfigPrettierFlat from "eslint-config-prettier/flat"; 4 | 5 | export default withNuxt( 6 | { 7 | rules: { 8 | "@typescript-eslint/no-invalid-void-type": "off", 9 | "@typescript-eslint/no-explicit-any": "off", 10 | "vue/no-multiple-template-root": "off", 11 | "vue/html-self-closing": "off", 12 | }, 13 | }, 14 | eslintConfigPrettierFlat, 15 | ); 16 | -------------------------------------------------------------------------------- /i18n/locales/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "welcome": "Welcome to removarr", 3 | "start_with": "Starts by login-in with your plex account", 4 | "settings": "Settings", 5 | "language": "Language", 6 | "movies": "Movies", 7 | "movie": "Movies", 8 | "shows": "TV Shows", 9 | "show": "TV Shows", 10 | "votes": "Votes", 11 | "users": "Users", 12 | "save": "Save", 13 | "edit": "Edit", 14 | "close": "Close", 15 | "confirm": "Confirm", 16 | "remove": "Remove", 17 | "remove_modal_title": "Remove selected medias", 18 | "remove_warning": "You are about to remove theses medias, are you sure ?", 19 | "delete_files_param": "Delete Files", 20 | "vote": "Vote", 21 | "error": "Error", 22 | "my_votes": "My Votes", 23 | "test": "Test", 24 | "login": "Login", 25 | "logout": "Logout", 26 | "next": "Next", 27 | "previous": "Previous", 28 | "done": "Done", 29 | "enabled": "Enabled", 30 | "disabled": "Disabled", 31 | "all_set": "All set", 32 | "configure": "Configure", 33 | "server": "server", 34 | "applications": "Applications", 35 | "interface": "Interface", 36 | "application_settings": "Manage your applications settings", 37 | "hostname": "Hostname", 38 | "ip": "IP", 39 | "port": "Port", 40 | "api_key": "Api Key", 41 | "plex_settings": "Manage your plex settings", 42 | "storage": "Storage", 43 | "step": "Step", 44 | "available": "available", 45 | "can_be_removed": "Can be removed", 46 | "user_wants_to_remove": "User wants to remove this media", 47 | "users_wants_to_remove": "Users wants to remove this media", 48 | "no_vote_yet": "No results, users haven't voted yet", 49 | "data_display_error": "Error : cannot display storage data", 50 | "selected_items": "Selected item(s)", 51 | "select_all": "Select All", 52 | "deselect_all": "Unselect All", 53 | "vote_registered": "Vote registered", 54 | "server_connexion_success": "Server connexion success", 55 | "server_connexion_failed": "Server connexion failed", 56 | "media_loading_failed": "Error while loading medias", 57 | "check_servarr_settings": "Check Radarr and Sonarr settings", 58 | "items_per_page": "Items per page", 59 | "libraries_filter": "Libraries filter", 60 | "settings_saved": "Settings saved" 61 | } 62 | -------------------------------------------------------------------------------- /i18n/locales/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "welcome": "Bienvenue sur removarr", 3 | "start_with": "Pour commencer connect toi avec ton compte plex", 4 | "settings": "Paramètres", 5 | "language": "Langue", 6 | "movies": "Films", 7 | "movie": "Films", 8 | "shows": "Série TV", 9 | "show": "Série TV", 10 | "votes": "Votes", 11 | "users": "Utilisateurs", 12 | "save": "Sauvegarder", 13 | "edit": "Modifier", 14 | "close": "Fermer", 15 | "confirm": "Confirmer", 16 | "remove": "Supprimer", 17 | "remove_modal_title": "Supprimer les médias sélectionner", 18 | "remove_warning": "Vous êtes sur la point de supprimer ces médias, êtes-vous sûr ?", 19 | "delete_files_param": "Supprimer les fichiers", 20 | "vote": "Voter", 21 | "error": "Erreur", 22 | "my_votes": "Mes Votes", 23 | "test": "Tester", 24 | "login": "Connexion", 25 | "logout": "Déconnexion", 26 | "next": "Suivant", 27 | "previous": "Précédent", 28 | "done": "Terminé", 29 | "enabled": "Activé", 30 | "disabled": "Désactivé", 31 | "all_set": "Tout est prêt", 32 | "configure": "Configurer", 33 | "server": "serveur", 34 | "applications": "Applications", 35 | "interface": "Interface", 36 | "application_settings": "Régler les paramètres de vos applications", 37 | "hostname": "Hôte", 38 | "ip": "IP", 39 | "port": "Port", 40 | "api_key": "Clé API", 41 | "plex_settings": "Régler les paramètres de plex", 42 | "storage": "Stockage", 43 | "step": "Étape", 44 | "available": "Disponible", 45 | "can_be_removed": "Peut être supprimé", 46 | "user_wants_to_remove": "Utilisateur souhaite le supprimer", 47 | "users_wants_to_remove": "Utilisateurs souhaitent le supprimer", 48 | "no_vote_yet": "Aucun résultats, les utilisateurs n'ont pas encore voter", 49 | "data_display_error": "Erreur : impossible d'afficher les information de stockage", 50 | "selected_items": "Item(s) sélectionner", 51 | "select_all": "Tout sélectionner", 52 | "deselect_all": "Tout désélectionner", 53 | "vote_registered": "Vote pris en compte", 54 | "server_connexion_success": "Connexion au serveur réussi", 55 | "server_connexion_failed": "Échec de la connexion au serveur", 56 | "media_loading_failed": "Erreur lors du chargement des medias", 57 | "check_servarr_settings": "Vérifier vos paramètres Radarr et Sonarr", 58 | "items_per_page": "Items par page", 59 | "libraries_filter": "Filtre par bibliothèques", 60 | "settings_saved": "Paramètres sauvegarder" 61 | } 62 | -------------------------------------------------------------------------------- /layouts/default.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 160 | -------------------------------------------------------------------------------- /layouts/empty.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /middleware/setup.ts: -------------------------------------------------------------------------------- 1 | import type { MainSettings } from "~/server/repository/settingRepository"; 2 | 3 | export default defineNuxtRouteMiddleware(async () => { 4 | const settings = await $fetch("/api/settings"); 5 | const { data } = useAuth(); 6 | if ( 7 | !settings.radarr.hostname || 8 | !settings.radarr.apiKey || 9 | !settings.sonarr.hostname || 10 | !settings.sonarr.apiKey 11 | ) { 12 | if (data.value && data.value.role === "user") { 13 | // set user as admin 14 | await $fetch(`/api/users/${data.value.id}`, { 15 | method: "PUT", 16 | body: { 17 | id: data.value.id, 18 | role: "admin", 19 | }, 20 | }); 21 | } 22 | 23 | return navigateTo("/setup"); 24 | } 25 | return; 26 | }); 27 | -------------------------------------------------------------------------------- /nuxt.config.ts: -------------------------------------------------------------------------------- 1 | // https://nuxt.com/docs/api/configuration/nuxt-config 2 | import tailwindcss from "@tailwindcss/vite"; 3 | 4 | export default defineNuxtConfig({ 5 | app: { 6 | head: { 7 | meta: [ 8 | { 9 | name: "theme-color", 10 | content: "#181926", 11 | media: "(prefers-color-scheme: dark)", 12 | }, 13 | { 14 | name: "theme-color", 15 | content: "#dce0e8", 16 | media: "(prefers-color-scheme: light)", 17 | }, 18 | ], 19 | }, 20 | }, 21 | compatibilityDate: "2024-11-01", 22 | devtools: { enabled: true }, 23 | eslint: { 24 | checker: true, 25 | }, 26 | vite: { 27 | plugins: [tailwindcss()], 28 | server: { 29 | watch: { 30 | ignored: ["**/config/**"], 31 | }, 32 | }, 33 | }, 34 | nitro: { 35 | routeRules: { 36 | "/radarr/**": { 37 | proxy: { 38 | to: "/api/proxy/radarr/**", 39 | }, 40 | }, 41 | "/sonarr/**": { 42 | proxy: { 43 | to: "/api/proxy/sonarr/**", 44 | }, 45 | }, 46 | "/overseerr/**": { 47 | proxy: { 48 | to: "/api/proxy/overseerr/**", 49 | }, 50 | }, 51 | }, 52 | }, 53 | modules: [ 54 | "@cssninja/nuxt-toaster", 55 | "@sidebase/nuxt-auth", 56 | "@nuxt/eslint", 57 | "@vite-pwa/nuxt", 58 | "@nuxtjs/i18n", 59 | "@nuxt/image", 60 | ], 61 | runtimeConfig: { 62 | baseURL: "/api/auth", 63 | }, 64 | auth: { 65 | originEnvKey: "NUXT_BASE_URL", 66 | globalAppMiddleware: true, 67 | provider: { 68 | type: "local", 69 | session: { 70 | dataType: { 71 | id: "number", 72 | username: "string", 73 | email: "string", 74 | avatar: "string", 75 | role: "string", 76 | createdAt: "string", 77 | }, 78 | }, 79 | token: { 80 | type: "", 81 | headerName: "X-Plex-Token", 82 | maxAgeInSeconds: 2592000, 83 | }, 84 | refresh: { 85 | isEnabled: false, 86 | }, 87 | endpoints: { 88 | signIn: { path: "/login", method: "post" }, 89 | signOut: false, 90 | signUp: false, 91 | getSession: { path: "/user", method: "get" }, 92 | }, 93 | pages: { 94 | login: "/login", 95 | }, 96 | }, 97 | }, 98 | pwa: { 99 | manifest: { 100 | name: "Removarr", 101 | short_name: "removarr", 102 | theme_color: "#dce0e8", 103 | icons: [ 104 | { 105 | src: "pwa-192x192.png", 106 | sizes: "192x192", 107 | type: "image/png", 108 | }, 109 | { 110 | src: "pwa-512x512.png", 111 | sizes: "512x512", 112 | type: "image/png", 113 | }, 114 | { 115 | src: "pwa-512x512.png", 116 | sizes: "512x512", 117 | type: "image/png", 118 | purpose: "any maskable", 119 | }, 120 | ], 121 | }, 122 | workbox: { 123 | globPatterns: ["**/*.{js,css,html,png,svg,ico}"], 124 | runtimeCaching: [ 125 | { 126 | urlPattern: /^https:\/\/image\.tmdb\.org\/.*/i, 127 | handler: "CacheFirst", 128 | options: { 129 | cacheName: "tmdb", 130 | cacheableResponse: { 131 | statuses: [0, 200], 132 | }, 133 | }, 134 | }, 135 | { 136 | urlPattern: /^https:\/\/artworks\.thetvdb\.com\/.*/i, 137 | handler: "CacheFirst", 138 | options: { 139 | cacheName: "thetvdb", 140 | cacheableResponse: { 141 | statuses: [0, 200], 142 | }, 143 | }, 144 | }, 145 | ], 146 | }, 147 | injectManifest: { 148 | globPatterns: ["**/*.{js,css,html,png,svg,ico}"], 149 | }, 150 | client: { 151 | installPrompt: true, 152 | // you don't need to include this: only for testing purposes 153 | // if enabling periodic sync for update use 1 hour or so (periodicSyncForUpdates: 3600) 154 | periodicSyncForUpdates: 20, 155 | }, 156 | devOptions: { 157 | enabled: false, 158 | suppressWarnings: true, 159 | navigateFallback: "/", 160 | navigateFallbackAllowlist: [/^\/$/], 161 | type: "module", 162 | }, 163 | }, 164 | i18n: { 165 | strategy: "no_prefix", 166 | detectBrowserLanguage: { 167 | useCookie: true, 168 | cookieKey: "i18n_redirected", 169 | }, 170 | locales: [ 171 | { code: "en", name: "English", file: "en.json" }, 172 | { code: "fr", name: "Français", file: "fr.json" }, 173 | ], 174 | }, 175 | image: { 176 | domains: ["image.tmdb.org", "artworks.thetvdb.com"], 177 | }, 178 | css: ["~/assets/app.css"], 179 | }); 180 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nuxt-app", 3 | "private": true, 4 | "type": "module", 5 | "scripts": { 6 | "build": "nuxt build", 7 | "dev": "nuxt dev", 8 | "generate": "nuxt generate", 9 | "generate:pwa-assets": "pwa-assets-generator --preset minimal-2023 public/logo.svg", 10 | "preview": "nuxt preview", 11 | "postinstall": "nuxt prepare", 12 | "db:generate": "drizzle-kit generate", 13 | "db:migrate": "drizzle-kit migrate", 14 | "lint": "npm run lint:eslint && npm run lint:prettier", 15 | "lint:eslint": "eslint .", 16 | "lint:prettier": "prettier . --check", 17 | "lint:fix": "eslint . --fix && prettier --write --list-different .", 18 | "docs:dev": "vitepress dev docs", 19 | "docs:build": "vitepress build docs", 20 | "docs:preview": "vitepress preview docs" 21 | }, 22 | "dependencies": { 23 | "@nuxt/eslint": "^1.4.0", 24 | "@nuxt/image": "^1.10.0", 25 | "@nuxtjs/i18n": "^9.5.4", 26 | "@vite-pwa/nuxt": "^1.0.1", 27 | "better-sqlite3": "^11.10.0", 28 | "bowser": "^2.11.0", 29 | "drizzle-orm": "^0.43.1", 30 | "lodash": "^4.17.21", 31 | "nuxt": "^3.17.2", 32 | "plex-api": "^5.3.2", 33 | "vue-router": "^4.5.1", 34 | "xml2js": "^0.6.2" 35 | }, 36 | "devDependencies": { 37 | "@catppuccin/daisyui": "^2.1.1", 38 | "@cssninja/nuxt-toaster": "^0.3.12", 39 | "@sidebase/nuxt-auth": "^0.10.1", 40 | "@tailwindcss/typography": "^0.5.16", 41 | "@tailwindcss/vite": "^4.1.6", 42 | "@types/better-sqlite3": "^7.6.13", 43 | "@vite-pwa/assets-generator": "^1.0.0", 44 | "@vue/typescript-plugin": "^2.2.10", 45 | "daisyui": "^5.0.35", 46 | "drizzle-kit": "^0.31.1", 47 | "eslint": "^9.27.0", 48 | "eslint-config-prettier": "^10.1.5", 49 | "prettier": "^3.5.3", 50 | "tailwindcss": "^4.1.6", 51 | "typescript": "^5.8.3", 52 | "vite-plugin-eslint2": "^5.0.3", 53 | "vitepress": "^1.6.3" 54 | }, 55 | "overrides": { 56 | "vue": "latest" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /pages/index.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /pages/login/index.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /pages/login/plex/loading.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /pages/movies.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /pages/profile.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /pages/remove.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /pages/settings.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /pages/setup.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /pages/shows.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /pages/user/votes.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /pages/users.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /public/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/public/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/public/favicon.ico -------------------------------------------------------------------------------- /public/images/party.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/public/images/party.webp -------------------------------------------------------------------------------- /public/images/plex.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/images/radarr.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/images/sonarr.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /public/maskable-icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/public/maskable-icon-512x512.png -------------------------------------------------------------------------------- /public/preview.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/public/preview.webp -------------------------------------------------------------------------------- /public/pwa-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/public/pwa-192x192.png -------------------------------------------------------------------------------- /public/pwa-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/public/pwa-512x512.png -------------------------------------------------------------------------------- /public/pwa-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Thomas-Philippot/removarr/a52adda8c4d9e0d493677811bb6e226fbc5767a6/public/pwa-64x64.png -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-Agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /server/api/auth/login.post.ts: -------------------------------------------------------------------------------- 1 | export default defineEventHandler(async (event) => { 2 | const data = await readBody(event); 3 | 4 | return { token: data.authToken }; 5 | }); 6 | -------------------------------------------------------------------------------- /server/api/auth/user.get.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | interface PlexUserResponse { 3 | user: { 4 | id: number; 5 | uuid: string; 6 | email: string; 7 | joined_at: string; 8 | username: string; 9 | thumb: string; 10 | authToken: string; 11 | }; 12 | } 13 | 14 | export default defineEventHandler(async (event) => { 15 | const settings = getSettings().load(); 16 | const response: PlexUserResponse = await event.$fetch( 17 | "https://plex.tv/users/account.json", 18 | ); 19 | const user = response.user; 20 | 21 | const exist = await $fetch(`/api/users/${user.uuid}`); 22 | if (!exist) { 23 | if (settings.main.plex.machineId) { 24 | // check if user has access to plex shared library 25 | const plexUsers = await $fetch("/api/plex/users"); 26 | const plexUser = plexUsers?.find((u) => parseInt(u.$.id) === user.id); 27 | if (!plexUser) { 28 | // access denied 29 | return false; 30 | } 31 | 32 | const inServer = plexUser?.Server?.find( 33 | (server) => server.$.machineIdentifier === settings.main.plex.machineId, 34 | ); 35 | 36 | if (!inServer) { 37 | // access denied 38 | return false; 39 | } 40 | } 41 | 42 | return await $fetch(`/api/users`, { 43 | method: "POST", 44 | body: { 45 | id: user.uuid, 46 | username: user.username, 47 | avatar: user.thumb, 48 | email: user.email, 49 | createdAt: user.joined_at, 50 | }, 51 | }); 52 | } 53 | 54 | // Token refresh if changed 55 | if ( 56 | exist.role === "admin" && 57 | user.authToken !== settings.main.plex.auth_token 58 | ) { 59 | await $fetch("/api/settings/plex", { 60 | method: "POST", 61 | body: { 62 | auth_token: user.authToken, 63 | }, 64 | }); 65 | } 66 | 67 | return exist; 68 | }); 69 | -------------------------------------------------------------------------------- /server/api/imdb/backdrops/index.get.ts: -------------------------------------------------------------------------------- 1 | export default defineEventHandler(async () => { 2 | const data = await $fetch( 3 | "https://api.themoviedb.org/3/trending/all/day?api_key=12eaa43ab98e6a3452d414c6eb4e2406", 4 | ); 5 | return data.results 6 | .filter((x) => x.media_type !== "person") 7 | .map((x) => "https://image.tmdb.org/t/p/original" + x.backdrop_path) 8 | .filter((backdropPath) => !!backdropPath); 9 | }); 10 | -------------------------------------------------------------------------------- /server/api/plex/setup/index.post.ts: -------------------------------------------------------------------------------- 1 | import { 2 | getSettings, 3 | type PlexLibrary, 4 | } from "~/server/repository/settingRepository"; 5 | import PlexApi from "plex-api"; 6 | import { randomUUID } from "crypto"; 7 | 8 | export interface PlexResponse { 9 | MediaContainer: { 10 | size: number; 11 | allowSync: boolean; 12 | title1: string; 13 | Directory: PlexLibraryResponse[]; 14 | }; 15 | } 16 | 17 | interface PlexLibraryResponse { 18 | allowSync: boolean; 19 | art: string; 20 | composite: string; 21 | filters: boolean; 22 | refreshing: boolean; 23 | thumb: string; 24 | key: string; 25 | type: string; 26 | title: string; 27 | agent: string; 28 | scanner: string; 29 | language: string; 30 | uuid: string; 31 | updatedAt: number; 32 | createdAt: number; 33 | scannedAt: number; 34 | content: boolean; 35 | directory: boolean; 36 | contentChangedAt: number; 37 | hidden: number; 38 | Location: PlexLocationResponse[]; 39 | } 40 | 41 | interface PlexLocationResponse { 42 | id: number; 43 | path: string; 44 | } 45 | 46 | export default defineEventHandler(async (event) => { 47 | const settings = getSettings().load(); 48 | const data = await readBody(event); 49 | const token = data.token; 50 | 51 | let hostname = settings.main.plex.hostname; 52 | if (settings.main.plex.mode === "ip") { 53 | hostname = settings.main.plex.ip; 54 | } 55 | 56 | const client = new PlexApi({ 57 | hostname, 58 | port: settings.main.plex.port, 59 | https: settings.main.plex.schema === "https://", 60 | token, 61 | authenticator: { 62 | authenticate: ( 63 | _plexApi: PlexApi, 64 | cb: (err?: string, token?: string) => void, 65 | ) => { 66 | if (!token) { 67 | return cb("Plex Token not found!"); 68 | } 69 | cb(undefined, token); 70 | }, 71 | }, 72 | // requestOptions: { 73 | // includeChildren: 1, 74 | // }, 75 | options: { 76 | identifier: data.uuid, 77 | product: "Removarr", 78 | deviceName: "Removarr", 79 | platform: "Removarr", 80 | }, 81 | }); 82 | 83 | if (!settings.main.plex.api_uuid) { 84 | settings.main.plex.api_uuid = randomUUID(); 85 | } 86 | 87 | if (data.token) { 88 | settings.main.plex.auth_token = data.token; 89 | } 90 | 91 | const status = await client.query("/"); 92 | if (!status?.MediaContainer?.machineIdentifier) { 93 | throw createError({ 94 | statusCode: 400, 95 | statusMessage: "Server not found", 96 | }); 97 | } 98 | 99 | settings.main.plex.machineId = status.MediaContainer.machineIdentifier; 100 | 101 | settings.save(); 102 | 103 | try { 104 | const response: PlexResponse = await client.query("/library/sections"); 105 | const libraries = response.MediaContainer.Directory; 106 | 107 | settings.main.plex.libraries = libraries 108 | // Remove setup that are not movie or show 109 | .filter((library) => library.type === "movie" || library.type === "show") 110 | // Remove setup that do not have a metadata agent set (usually personal video setup) 111 | .filter((library) => library.agent !== "com.plexapp.agents.none") 112 | .map((library) => { 113 | const existing = settings.main.plex.libraries.find( 114 | (l) => l.id === library.key && l.name === library.title, 115 | ); 116 | 117 | return { 118 | id: library.key, 119 | name: library.title, 120 | enabled: existing?.enabled ?? true, 121 | type: library.type, 122 | path: library.Location[0].path, 123 | } as PlexLibrary; 124 | }); 125 | settings.save(); 126 | } catch (error) { 127 | console.log(error); 128 | return createError({ 129 | statusCode: 500, 130 | statusMessage: "Plex Server error", 131 | }); 132 | } 133 | }); 134 | -------------------------------------------------------------------------------- /server/api/plex/token/index.post.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | 3 | export default defineEventHandler(async (event) => { 4 | const settings = getSettings().load(); 5 | const data = await readBody(event); 6 | if (data.token) { 7 | settings.main.plex.auth_token = data.token; 8 | } 9 | settings.save(); 10 | }); 11 | -------------------------------------------------------------------------------- /server/api/plex/users/index.get.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | import xml2js from "xml2js"; 3 | 4 | interface UsersResponse { 5 | MediaContainer: { 6 | User: { 7 | $: { 8 | id: string; 9 | title: string; 10 | username: string; 11 | email: string; 12 | thumb: string; 13 | }; 14 | Server: ServerResponse[]; 15 | }[]; 16 | }; 17 | } 18 | 19 | interface ServerResponse { 20 | $: { 21 | id: string; 22 | serverId: string; 23 | machineIdentifier: string; 24 | name: string; 25 | lastSeenAt: string; 26 | numLibraries: string; 27 | owned: string; 28 | }; 29 | } 30 | 31 | export default defineEventHandler(async () => { 32 | try { 33 | const settings = getSettings().load(); 34 | // const response: PlexResponse = await client.query("/users"); 35 | // console.log(response.MediaContainer) 36 | 37 | const response = await $fetch("https://plex.tv/api/users", { 38 | headers: { 39 | "X-Plex-Token": settings.main.plex.auth_token, 40 | }, 41 | responseType: "text", 42 | }); 43 | 44 | const parsedXml = (await xml2js.parseStringPromise( 45 | response, 46 | )) as UsersResponse; 47 | 48 | return parsedXml.MediaContainer.User; 49 | } catch (error) { 50 | console.log(error); 51 | return; 52 | } 53 | }); 54 | -------------------------------------------------------------------------------- /server/api/proxy/radarr/[...]/index.delete.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | 3 | export default defineEventHandler(async (event) => { 4 | const data = await readBody(event); 5 | if (!event.context.params) { 6 | throw createError({ 7 | statusCode: 400, 8 | statusMessage: "missing url parameter", 9 | }); 10 | } 11 | 12 | const settings = getSettings().load(); 13 | if (!settings.main.radarr.apiKey) { 14 | throw createError({ 15 | statusCode: 400, 16 | statusMessage: "Missing radarr api key", 17 | }); 18 | } 19 | const param = event.context.params._; 20 | const path = param.replace("/radarr/", ""); 21 | const url = 22 | settings.main.radarr.mode === "ip" 23 | ? `${settings.main.radarr.schema}${settings.main.radarr.ip}:${settings.main.radarr.port}/${path}` 24 | : `${settings.main.radarr.schema}${settings.main.radarr.hostname}/${path}`; 25 | return await $fetch(url, { 26 | method: "DELETE", 27 | body: data, 28 | headers: { 29 | "X-Api-Key": settings.main.radarr.apiKey, 30 | }, 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /server/api/proxy/radarr/[...]/index.get.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | 3 | export default defineEventHandler(async (event) => { 4 | if (!event.context.params) { 5 | throw createError({ 6 | statusCode: 400, 7 | statusMessage: "missing url parameter", 8 | }); 9 | } 10 | 11 | const settings = getSettings().load(); 12 | if (!settings.main.radarr.apiKey) { 13 | throw createError({ 14 | statusCode: 400, 15 | statusMessage: "Missing radarr api key", 16 | }); 17 | } 18 | const param = event.context.params._; 19 | const path = param.replace("/radarr/", ""); 20 | 21 | const url = 22 | settings.main.radarr.mode === "ip" 23 | ? `${settings.main.radarr.schema}${settings.main.radarr.ip}:${settings.main.radarr.port}/${path}` 24 | : `${settings.main.radarr.schema}${settings.main.radarr.hostname}/${path}`; 25 | return await $fetch(url, { 26 | headers: { 27 | "X-Api-Key": settings.main.radarr.apiKey, 28 | }, 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /server/api/proxy/sonarr/[...]/index.delete.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | 3 | export default defineEventHandler(async (event) => { 4 | const data = await readBody(event); 5 | if (!event.context.params) { 6 | throw createError({ 7 | statusCode: 400, 8 | statusMessage: "missing url parameter", 9 | }); 10 | } 11 | 12 | const settings = getSettings().load(); 13 | if (!settings.main.sonarr.apiKey) { 14 | throw createError({ 15 | statusCode: 400, 16 | statusMessage: "Sonarr api key missing", 17 | }); 18 | } 19 | 20 | const param = event.context.params._; 21 | const path = param.replace("/sonarr/", ""); 22 | 23 | const url = 24 | settings.main.sonarr.mode === "ip" 25 | ? `${settings.main.sonarr.schema}${settings.main.sonarr.ip}:${settings.main.sonarr.port}/${path}` 26 | : `${settings.main.sonarr.schema}${settings.main.sonarr.hostname}/${path}`; 27 | return await $fetch(url, { 28 | method: "DELETE", 29 | body: data, 30 | headers: { 31 | "X-Api-Key": settings.main.sonarr.apiKey, 32 | }, 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /server/api/proxy/sonarr/[...]/index.get.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | 3 | export default defineEventHandler(async (event) => { 4 | if (!event.context.params) { 5 | throw createError({ 6 | statusCode: 400, 7 | statusMessage: "missing url parameter", 8 | }); 9 | } 10 | 11 | const settings = getSettings().load(); 12 | if (!settings.main.sonarr.apiKey) { 13 | throw createError({ 14 | statusCode: 400, 15 | statusMessage: "Sonarr api key missing", 16 | }); 17 | } 18 | 19 | const param = event.context.params._; 20 | const path = param.replace("/sonarr/", ""); 21 | 22 | const url = 23 | settings.main.sonarr.mode === "ip" 24 | ? `${settings.main.sonarr.schema}${settings.main.sonarr.ip}:${settings.main.sonarr.port}/${path}` 25 | : `${settings.main.sonarr.schema}${settings.main.sonarr.hostname}/${path}`; 26 | return await $fetch(url, { 27 | headers: { 28 | "X-Api-Key": settings.main.sonarr.apiKey, 29 | }, 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /server/api/proxy/sonarr/[...]/index.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | 3 | export default defineEventHandler(async (event) => { 4 | if (!event.context.params) { 5 | throw createError({ 6 | statusCode: 400, 7 | statusMessage: "missing url parameter", 8 | }); 9 | } 10 | 11 | const settings = getSettings().load(); 12 | if (!settings.main.sonarr.apiKey) { 13 | throw createError({ 14 | statusCode: 400, 15 | statusMessage: "Sonarr api key missing", 16 | }); 17 | } 18 | 19 | const param = event.context.params._; 20 | const path = param.replace("/sonarr/", ""); 21 | 22 | const url = 23 | settings.main.sonarr.mode === "ip" 24 | ? `${settings.main.sonarr.schema}${settings.main.sonarr.ip}:${settings.main.sonarr.port}/${path}` 25 | : `${settings.main.sonarr.schema}${settings.main.sonarr.hostname}/${path}`; 26 | return await $fetch(url, { 27 | headers: { 28 | "X-Api-Key": settings.main.sonarr.apiKey, 29 | }, 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /server/api/settings/[...servarr]/index.get.ts: -------------------------------------------------------------------------------- 1 | import { 2 | getSettings, 3 | type DVRSettings, 4 | } from "~/server/repository/settingRepository"; 5 | 6 | export default defineEventHandler(async (event) => { 7 | const settings = getSettings().load(); 8 | const key = event.context.params?.servarr; 9 | if (key === "radarr" || key === "sonarr" || key === "overseerr") { 10 | return settings.main[key] as DVRSettings; 11 | } 12 | throw createError({ 13 | statusCode: 400, 14 | statusMessage: "servarr not implemented", 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /server/api/settings/[...servarr]/index.post.ts: -------------------------------------------------------------------------------- 1 | import { 2 | getSettings, 3 | type MainSettings, 4 | } from "~/server/repository/settingRepository"; 5 | import merge from "lodash/merge.js"; 6 | 7 | export default defineEventHandler(async (event) => { 8 | const settings = getSettings().load(); 9 | const key = event.context.params?.servarr; 10 | if (key && key in settings.main) { 11 | const data = await readBody(event); 12 | 13 | settings.main[key as keyof MainSettings] = merge( 14 | settings.main[key as keyof MainSettings], 15 | data, 16 | ); 17 | settings.save(); 18 | return settings.main; 19 | } 20 | throw createError({ 21 | statusCode: 400, 22 | statusMessage: "servarr not implemented", 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /server/api/settings/index.get.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | 3 | export default defineEventHandler(async () => { 4 | const settings = getSettings().load(); 5 | return settings.main; 6 | }); 7 | -------------------------------------------------------------------------------- /server/api/settings/index.post.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | import merge from "lodash/merge"; 3 | 4 | export default defineEventHandler(async (event) => { 5 | const settings = getSettings().load(); 6 | const data = await readBody(event); 7 | 8 | settings.main = merge(settings.main, data); 9 | settings.save(); 10 | return settings.main; 11 | }); 12 | -------------------------------------------------------------------------------- /server/api/settings/plex/index.get.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | 3 | export default defineEventHandler(async () => { 4 | const settings = getSettings().load(); 5 | return settings.main.plex; 6 | }); 7 | -------------------------------------------------------------------------------- /server/api/settings/plex/index.post.ts: -------------------------------------------------------------------------------- 1 | import { getSettings } from "~/server/repository/settingRepository"; 2 | import merge from "lodash/merge.js"; 3 | 4 | export default defineEventHandler(async (event) => { 5 | const settings = getSettings().load(); 6 | const data = await readBody(event); 7 | 8 | settings.main.plex = merge(settings.main.plex, data); 9 | settings.save(); 10 | return settings.main.plex; 11 | }); 12 | -------------------------------------------------------------------------------- /server/api/users/[...id]/index.get.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { user } from "~/server/database/schema"; 3 | import { eq } from "drizzle-orm"; 4 | 5 | export default defineEventHandler(async (event) => { 6 | try { 7 | const id = event.context.params?.id as string; 8 | return db.select().from(user).where(eq(user.id, id)).get(); 9 | } catch (error: any) { 10 | throw createError({ 11 | statusCode: 400, 12 | statusMessage: error.message, 13 | }); 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /server/api/users/[...id]/index.put.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { user } from "~/server/database/schema"; 3 | import { eq } from "drizzle-orm"; 4 | 5 | export default defineEventHandler(async (event) => { 6 | try { 7 | const data = await readBody(event); 8 | await db.update(user).set(data).where(eq(user.id, data.id)); 9 | } catch (error: any) { 10 | throw createError({ 11 | statusCode: 400, 12 | statusMessage: error.message, 13 | }); 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /server/api/users/index.get.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { user } from "~/server/database/schema"; 3 | 4 | export default defineEventHandler(async () => { 5 | return db.select().from(user).all(); 6 | }); 7 | -------------------------------------------------------------------------------- /server/api/users/index.post.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { user } from "~/server/database/schema"; 3 | 4 | export default defineEventHandler(async (event) => { 5 | try { 6 | const data = await readBody(event); 7 | const results = await db.insert(user).values(data).returning(); 8 | return results[0]; 9 | } catch (error: any) { 10 | throw createError({ 11 | statusCode: 400, 12 | statusMessage: error.message, 13 | }); 14 | } 15 | }); 16 | -------------------------------------------------------------------------------- /server/api/votes/index.get.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { vote } from "~/server/database/schema"; 3 | 4 | export default defineEventHandler(() => { 5 | return db.select().from(vote).all(); 6 | }); 7 | -------------------------------------------------------------------------------- /server/api/votes/index.post.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { vote } from "~/server/database/schema"; 3 | 4 | interface Vote { 5 | mediaId: string; 6 | servarrId: number; 7 | } 8 | 9 | interface MultipleVotes { 10 | medias: Vote[]; 11 | userId: string; 12 | mediaType: string; 13 | } 14 | 15 | export default defineEventHandler(async (event) => { 16 | try { 17 | const data: MultipleVotes = await readBody(event); 18 | const voteInserts = data.medias.map((item) => ({ 19 | mediaId: item.mediaId, 20 | userId: data.userId, 21 | mediaType: data.mediaType, 22 | servarrId: item.servarrId, 23 | })); 24 | await db.insert(vote).values(voteInserts); 25 | return { response: "Ok" }; 26 | } catch (error: any) { 27 | throw createError({ 28 | statusCode: 400, 29 | statusMessage: error.message, 30 | }); 31 | } 32 | }); 33 | -------------------------------------------------------------------------------- /server/api/votes/media/[...mediaId]/index.delete.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { vote } from "~/server/database/schema"; 3 | import { and, eq } from "drizzle-orm"; 4 | 5 | export default defineEventHandler(async (event) => { 6 | const params = event.context.params?.mediaId; 7 | 8 | if (params) { 9 | const [mediaId, userId] = params.split("/"); 10 | 11 | if (!userId) { 12 | return db.delete(vote).where(eq(vote.mediaId, mediaId)); 13 | } 14 | return db 15 | .delete(vote) 16 | .where(and(eq(vote.mediaId, mediaId), eq(vote.userId, userId))); 17 | } 18 | 19 | throw createError({ 20 | statusCode: 400, 21 | statusMessage: "Missing mediaId query parameter", 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /server/api/votes/results/index.delete.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { vote } from "~/server/database/schema"; 3 | import { eq, and } from "drizzle-orm"; 4 | 5 | interface MultipleVotes { 6 | medias: string[]; 7 | mediaType: "movie" | "show"; 8 | deleteFiles: boolean; 9 | } 10 | 11 | export default defineEventHandler(async (event) => { 12 | try { 13 | const data: MultipleVotes = await readBody(event); 14 | 15 | const url = { 16 | movie: "/radarr/api/v3/movie", 17 | show: "/sonarr/api/v3/series", 18 | }; 19 | 20 | for (const item of data.medias) { 21 | const id = parseInt(item); 22 | const res = await $fetch(url[data.mediaType] + "/" + id, { 23 | method: "DELETE", 24 | }); 25 | console.log(res); 26 | await db 27 | .delete(vote) 28 | .where(and(eq(vote.servarrId, id), eq(vote.mediaType, data.mediaType))); 29 | } 30 | 31 | return { response: "Ok" }; 32 | } catch (error: any) { 33 | throw createError({ 34 | statusCode: 400, 35 | statusMessage: error.message, 36 | }); 37 | } 38 | }); 39 | -------------------------------------------------------------------------------- /server/api/votes/results/index.get.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { vote, user } from "~/server/database/schema"; 3 | import { eq } from "drizzle-orm"; 4 | 5 | type User = typeof user.$inferInsert; 6 | 7 | interface ResultReccord { 8 | mediaId: string; 9 | mediaType: string | null; 10 | servarrId: string | null; 11 | users: User[]; 12 | } 13 | 14 | export default defineEventHandler(() => { 15 | const rows = db 16 | .select({ 17 | mediaId: vote.mediaId, 18 | mediaType: vote.mediaType, 19 | servarrId: vote.servarrId, 20 | user, 21 | }) 22 | .from(vote) 23 | .innerJoin(user, eq(vote.userId, user.id)) 24 | .all(); 25 | 26 | const result = rows.reduce>((acc, row) => { 27 | const mediaId = row.mediaId; 28 | const mediaType = row.mediaType; 29 | const servarrId = row.servarrId.toString(); 30 | const user = row.user; 31 | 32 | if (!acc[mediaId]) { 33 | acc[mediaId] = { mediaId, mediaType, servarrId, users: [] }; 34 | } 35 | 36 | if (mediaId) { 37 | acc[mediaId].users.push(user); 38 | } 39 | 40 | return acc; 41 | }, {}); 42 | 43 | return Object.values(result).sort((a, b) => b.users.length - a.users.length); 44 | }); 45 | -------------------------------------------------------------------------------- /server/api/votes/user/[...userId]/index.get.ts: -------------------------------------------------------------------------------- 1 | import { db } from "~/server/database"; 2 | import { vote } from "~/server/database/schema"; 3 | import { eq } from "drizzle-orm"; 4 | 5 | export default defineEventHandler(async (event) => { 6 | const userId = event.context.params?.userId; 7 | 8 | if (userId) { 9 | return db.select().from(vote).where(eq(vote.userId, userId)); 10 | } 11 | 12 | throw createError({ 13 | statusCode: 400, 14 | statusMessage: "Missing userId query parameter", 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /server/database/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | drizzle, 3 | type BetterSQLite3Database, 4 | } from "drizzle-orm/better-sqlite3"; 5 | import { migrate } from "drizzle-orm/better-sqlite3/migrator"; 6 | import Database from "better-sqlite3"; 7 | import { fileURLToPath } from "url"; 8 | import path from "path"; 9 | import fs from "fs"; 10 | 11 | const __filename = fileURLToPath(import.meta.url); 12 | const __dirname = path.dirname(__filename); 13 | 14 | const dbLocation = process.env.DATABASE_URL 15 | ? process.env.DATABASE_URL 16 | : "config/db/db.sqlite3"; 17 | 18 | // Create the 'config/db' folder if it doesn't exist 19 | const dbFolder = path.dirname(dbLocation); 20 | if (!fs.existsSync(dbFolder)) { 21 | fs.mkdirSync(dbFolder, { recursive: true }); 22 | } 23 | 24 | export const sqlite = new Database(dbLocation); 25 | export const db: BetterSQLite3Database = drizzle(sqlite); 26 | 27 | export const runMigration = () => { 28 | migrate(db, { 29 | migrationsFolder: "server/database/migrations", 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /server/database/migrations/0000_init.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `user` ( 2 | `id` text PRIMARY KEY NOT NULL, 3 | `username` text NOT NULL, 4 | `email` text NOT NULL, 5 | `avatar` text NOT NULL, 6 | `role` text DEFAULT 'user', 7 | `created_at` text DEFAULT (current_timestamp) NOT NULL 8 | ); 9 | --> statement-breakpoint 10 | CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);--> statement-breakpoint 11 | CREATE TABLE `vote` ( 12 | `media_id` text NOT NULL, 13 | `user_id` text NOT NULL, 14 | `media_type` text, 15 | `servarr_id` text NOT NULL, 16 | PRIMARY KEY(`media_id`, `user_id`) 17 | ); 18 | -------------------------------------------------------------------------------- /server/database/migrations/meta/0000_snapshot.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "6", 3 | "dialect": "sqlite", 4 | "id": "01a2bc35-9b23-4930-b844-377c68fe450e", 5 | "prevId": "00000000-0000-0000-0000-000000000000", 6 | "tables": { 7 | "user": { 8 | "name": "user", 9 | "columns": { 10 | "id": { 11 | "name": "id", 12 | "type": "text", 13 | "primaryKey": true, 14 | "notNull": true, 15 | "autoincrement": false 16 | }, 17 | "username": { 18 | "name": "username", 19 | "type": "text", 20 | "primaryKey": false, 21 | "notNull": true, 22 | "autoincrement": false 23 | }, 24 | "email": { 25 | "name": "email", 26 | "type": "text", 27 | "primaryKey": false, 28 | "notNull": true, 29 | "autoincrement": false 30 | }, 31 | "avatar": { 32 | "name": "avatar", 33 | "type": "text", 34 | "primaryKey": false, 35 | "notNull": true, 36 | "autoincrement": false 37 | }, 38 | "role": { 39 | "name": "role", 40 | "type": "text", 41 | "primaryKey": false, 42 | "notNull": false, 43 | "autoincrement": false, 44 | "default": "'user'" 45 | }, 46 | "created_at": { 47 | "name": "created_at", 48 | "type": "text", 49 | "primaryKey": false, 50 | "notNull": true, 51 | "autoincrement": false, 52 | "default": "(current_timestamp)" 53 | } 54 | }, 55 | "indexes": { 56 | "user_email_unique": { 57 | "name": "user_email_unique", 58 | "columns": ["email"], 59 | "isUnique": true 60 | } 61 | }, 62 | "foreignKeys": {}, 63 | "compositePrimaryKeys": {}, 64 | "uniqueConstraints": {}, 65 | "checkConstraints": {} 66 | }, 67 | "vote": { 68 | "name": "vote", 69 | "columns": { 70 | "media_id": { 71 | "name": "media_id", 72 | "type": "text", 73 | "primaryKey": false, 74 | "notNull": true, 75 | "autoincrement": false 76 | }, 77 | "user_id": { 78 | "name": "user_id", 79 | "type": "text", 80 | "primaryKey": false, 81 | "notNull": true, 82 | "autoincrement": false 83 | }, 84 | "media_type": { 85 | "name": "media_type", 86 | "type": "text", 87 | "primaryKey": false, 88 | "notNull": false, 89 | "autoincrement": false 90 | }, 91 | "servarr_id": { 92 | "name": "servarr_id", 93 | "type": "text", 94 | "primaryKey": false, 95 | "notNull": true, 96 | "autoincrement": false 97 | } 98 | }, 99 | "indexes": {}, 100 | "foreignKeys": {}, 101 | "compositePrimaryKeys": { 102 | "vote_media_id_user_id_pk": { 103 | "columns": ["media_id", "user_id"], 104 | "name": "vote_media_id_user_id_pk" 105 | } 106 | }, 107 | "uniqueConstraints": {}, 108 | "checkConstraints": {} 109 | } 110 | }, 111 | "views": {}, 112 | "enums": {}, 113 | "_meta": { 114 | "schemas": {}, 115 | "tables": {}, 116 | "columns": {} 117 | }, 118 | "internal": { 119 | "indexes": {} 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /server/database/migrations/meta/_journal.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "7", 3 | "dialect": "sqlite", 4 | "entries": [ 5 | { 6 | "idx": 0, 7 | "version": "6", 8 | "when": 1748601708773, 9 | "tag": "0000_init", 10 | "breakpoints": true 11 | } 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /server/database/schema.ts: -------------------------------------------------------------------------------- 1 | import { sql } from "drizzle-orm"; 2 | import { sqliteTable, text, primaryKey } from "drizzle-orm/sqlite-core"; 3 | 4 | export const user = sqliteTable("user", { 5 | id: text("id").primaryKey(), 6 | username: text("username").notNull(), 7 | email: text("email").notNull().unique(), 8 | avatar: text("avatar").notNull(), 9 | role: text("role").default("user"), 10 | createdAt: text("created_at") 11 | .notNull() 12 | .default(sql`(current_timestamp)`), 13 | }); 14 | 15 | export const vote = sqliteTable( 16 | "vote", 17 | { 18 | mediaId: text("media_id").notNull(), 19 | userId: text("user_id").notNull(), 20 | mediaType: text("media_type"), 21 | servarrId: text("servarr_id").notNull(), 22 | }, 23 | (table) => [primaryKey({ columns: [table.mediaId, table.userId] })], 24 | ); 25 | 26 | export type User = typeof user.$inferInsert; 27 | export type Vote = typeof vote.$inferInsert; 28 | -------------------------------------------------------------------------------- /server/plugins/dbInit.ts: -------------------------------------------------------------------------------- 1 | import { runMigration } from "~/server/database"; 2 | 3 | export default defineNitroPlugin(() => { 4 | runMigration(); 5 | }); 6 | -------------------------------------------------------------------------------- /server/repository/settingRepository.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import path from "path"; 3 | import { fileURLToPath } from "url"; 4 | import merge from "lodash/merge.js"; 5 | 6 | const __filename = fileURLToPath(import.meta.url); 7 | const __dirname = path.dirname(__filename); 8 | 9 | const SETTINGS_PATH = process.env.CONFIG_DIRECTORY 10 | ? `${process.env.CONFIG_DIRECTORY}/settings.json` 11 | : path.join(__dirname, "../../config/settings.json"); 12 | 13 | export interface DVRSettings { 14 | mode: "hostname" | "ip"; 15 | schema: "http://" | "https://"; 16 | hostname: string | null; 17 | ip: string | null; 18 | port: number; 19 | apiKey: string | null; 20 | } 21 | 22 | export interface PlexSettings { 23 | mode: "hostname" | "ip"; 24 | schema: "http://" | "https://"; 25 | hostname: string | null; 26 | ip: string | null; 27 | port: number; 28 | libraries: PlexLibrary[]; 29 | filter: boolean; 30 | api_uuid: string | null; 31 | auth_token?: string; 32 | machineId?: string | null; 33 | } 34 | 35 | export interface PlexLibrary { 36 | id: string; 37 | name: string; 38 | enabled: boolean; 39 | type: string; 40 | path: string; 41 | } 42 | 43 | export interface MainSettings { 44 | plex: PlexSettings; 45 | radarr: DVRSettings; 46 | sonarr: DVRSettings; 47 | overseerr: DVRSettings; 48 | } 49 | 50 | class Settings { 51 | private data: MainSettings; 52 | 53 | constructor(initialSettings?: MainSettings) { 54 | this.data = { 55 | plex: { 56 | mode: "hostname", 57 | schema: "http://", 58 | hostname: null, 59 | ip: null, 60 | port: 32400, 61 | libraries: [], 62 | filter: false, 63 | api_uuid: null, 64 | }, 65 | radarr: { 66 | mode: "hostname", 67 | hostname: null, 68 | schema: "https://", 69 | ip: null, 70 | port: 7878, 71 | apiKey: null, 72 | }, 73 | sonarr: { 74 | mode: "hostname", 75 | hostname: null, 76 | schema: "https://", 77 | ip: null, 78 | port: 8989, 79 | apiKey: null, 80 | }, 81 | overseerr: { 82 | mode: "hostname", 83 | hostname: null, 84 | schema: "https://", 85 | ip: null, 86 | port: 5055, 87 | apiKey: null, 88 | }, 89 | }; 90 | if (initialSettings) { 91 | this.data = merge(this.data, initialSettings); 92 | } 93 | } 94 | 95 | get main(): MainSettings { 96 | return this.data; 97 | } 98 | 99 | set main(data: MainSettings) { 100 | this.data = data; 101 | } 102 | 103 | /** 104 | * Settings Load 105 | * 106 | * This will load settings from file unless an optional argument of the object structure 107 | * is passed in. 108 | * @param overrideSettings If passed in, will override all existing settings with these 109 | * values 110 | */ 111 | public load(overrideSettings?: MainSettings): Settings { 112 | if (overrideSettings) { 113 | this.data = overrideSettings; 114 | return this; 115 | } 116 | 117 | if (!fs.existsSync(SETTINGS_PATH)) { 118 | this.save(); 119 | } 120 | const data = fs.readFileSync(SETTINGS_PATH, "utf-8"); 121 | 122 | if (data) { 123 | this.data = merge(this.data, JSON.parse(data)); 124 | this.save(); 125 | } 126 | return this; 127 | } 128 | 129 | public save(): void { 130 | fs.writeFileSync(SETTINGS_PATH, JSON.stringify(this.data, undefined, " ")); 131 | } 132 | } 133 | 134 | let settings: Settings | undefined; 135 | 136 | export const getSettings = (initialSettings?: MainSettings): Settings => { 137 | if (!settings) { 138 | settings = new Settings(initialSettings); 139 | } 140 | 141 | return settings; 142 | }; 143 | 144 | export default Settings; 145 | -------------------------------------------------------------------------------- /server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../.nuxt/tsconfig.server.json" 3 | } 4 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // https://nuxt.com/docs/guide/concepts/typescript 3 | "extends": "./.nuxt/tsconfig.json" 4 | } 5 | -------------------------------------------------------------------------------- /types/global.d.ts: -------------------------------------------------------------------------------- 1 | export interface AlternateTitle { 2 | title: string; 3 | sceneSeasonNumber?: number; 4 | sourceType?: string; 5 | movieMetadataId?: number; 6 | id?: number; 7 | } 8 | 9 | export interface Image { 10 | coverType: string; 11 | url: string; 12 | remoteUrl: string; 13 | } 14 | 15 | export interface OriginalLanguage { 16 | id: number; 17 | name: string; 18 | } 19 | 20 | export interface Statistics { 21 | sizeOnDisk: number; 22 | releaseGroups: string[]; 23 | seasonCount?: number; 24 | episodeFileCount?: number; 25 | episodeCount?: number; 26 | totalEpisodeCount?: number; 27 | percentOfEpisodes?: number; 28 | movieFileCount?: number; 29 | } 30 | 31 | export interface MediaStatistics { 32 | seasonNumber: number; 33 | monitored: boolean; 34 | statistics: { 35 | episodeFileCount: number; 36 | episodeCount: number; 37 | totalEpisodeCount: number; 38 | sizeOnDisk: number; 39 | releaseGroups: string[]; 40 | percentOfEpisodes: number; 41 | }; 42 | } 43 | 44 | export interface Season { 45 | seasonNumber: number; 46 | monitored: boolean; 47 | statistics: MediaStatistics; 48 | } 49 | 50 | export interface Ratings { 51 | votes?: number; 52 | value?: number; 53 | imdb?: { 54 | votes: number; 55 | value: number; 56 | type: string; 57 | }; 58 | tmdb?: { 59 | votes: number; 60 | value: number; 61 | type: string; 62 | }; 63 | metacritic?: { 64 | votes: number; 65 | value: number; 66 | type: string; 67 | }; 68 | rottenTomatoes?: { 69 | votes: number; 70 | value: number; 71 | type: string; 72 | }; 73 | } 74 | 75 | export interface Language { 76 | id: number; 77 | name: string; 78 | } 79 | 80 | export interface Quality { 81 | quality: { 82 | id: number; 83 | name: string; 84 | source: string; 85 | resolution: number; 86 | modifier: string; 87 | }; 88 | revision: { 89 | version: number; 90 | real: number; 91 | isRepack: boolean; 92 | }; 93 | } 94 | 95 | export interface MediaInfo { 96 | audioBitrate: number; 97 | audioChannels: string; 98 | audioCodec: string; 99 | audioLanguages: string; 100 | audioStreamCount: number; 101 | videoBitDepth: number; 102 | videoBitrate: number; 103 | videoCodec: string; 104 | videoFps: number; 105 | videoDynamicRange: string; 106 | videoDynamicRangeType: string; 107 | resolution: string; 108 | runTime: string; 109 | scanType: string; 110 | subtitles: string; 111 | } 112 | 113 | export interface MovieFile { 114 | movieId: number; 115 | relativePath: string; 116 | path: string; 117 | size: number; 118 | dateAdded: string; 119 | sceneName: string; 120 | releaseGroup: string; 121 | edition: string; 122 | languages: Language[]; 123 | quality: Quality; 124 | indexerFlags: number; 125 | mediaInfo: MediaInfo; 126 | originalFilePath: string; 127 | qualityCutoffNotMet: boolean; 128 | id: number; 129 | } 130 | 131 | export interface Media { 132 | title: string; 133 | alternateTitles: AlternateTitle[]; 134 | sortTitle: string; 135 | status: string; 136 | overview: string; 137 | images: Image[]; 138 | year?: number; 139 | path?: string; 140 | qualityProfileId: number; 141 | monitored: boolean; 142 | runtime: number; 143 | cleanTitle: string; 144 | imdbId: string; 145 | tmdbId: number; 146 | titleSlug: string; 147 | rootFolderPath: string; 148 | certification: string; 149 | genres: string[]; 150 | tags: string[]; 151 | added: string; 152 | ratings: Ratings; 153 | statistics: Statistics; 154 | id: number; 155 | } 156 | 157 | export interface Movie extends Media { 158 | originalTitle: string; 159 | secondaryYearSourceId: number; 160 | inCinemas: string; 161 | physicalRelease: string; 162 | digitalRelease: string; 163 | releaseDate: string; 164 | website: string; 165 | youTubeTrailerId: string; 166 | studio: string; 167 | hasFile: boolean; 168 | movieFileId: number; 169 | minimumAvailability: string; 170 | isAvailable: boolean; 171 | folderName: string; 172 | movieFile: MovieFile; 173 | popularity: number; 174 | lastSearchTime: string; 175 | } 176 | 177 | export interface TVShow extends Media { 178 | ended: boolean; 179 | network: string; 180 | airTime: string; 181 | originalLanguage: OriginalLanguage; 182 | seasons: Season[]; 183 | seasonFolder: boolean; 184 | useSceneNumbering: boolean; 185 | } 186 | 187 | export type MediaResponse = Media[]; 188 | -------------------------------------------------------------------------------- /utils/plex.ts: -------------------------------------------------------------------------------- 1 | import Bowser from "bowser"; 2 | 3 | interface PlexHeaders extends Record { 4 | Accept: string; 5 | "X-Plex-Product": string; 6 | "X-Plex-Version": string; 7 | "X-Plex-Client-Identifier": string; 8 | "X-Plex-Model": string; 9 | "X-Plex-Platform": string; 10 | "X-Plex-Platform-Version": string; 11 | "X-Plex-Device": string; 12 | "X-Plex-Device-Name": string; 13 | "X-Plex-Device-Screen-Resolution": string; 14 | "X-Plex-Language": string; 15 | } 16 | 17 | export interface PlexPin { 18 | id: number; 19 | code: string; 20 | } 21 | 22 | const uuidv4 = (): string => { 23 | return ((1e7).toString() + -1e3 + -4e3 + -8e3 + -1e11).replace( 24 | /[018]/g, 25 | function (c) { 26 | return ( 27 | parseInt(c) ^ 28 | (window.crypto.getRandomValues(new Uint8Array(1))[0] & 29 | (15 >> (parseInt(c) / 4))) 30 | ).toString(16); 31 | }, 32 | ); 33 | }; 34 | 35 | class PlexOAuth { 36 | private plexHeaders?: PlexHeaders; 37 | 38 | private pin?: PlexPin; 39 | private popup?: Window; 40 | 41 | private authToken?: string; 42 | 43 | public initializeHeaders(): void { 44 | if (!window) { 45 | throw new Error( 46 | "Window is not defined. Are you calling this in the browser?", 47 | ); 48 | } 49 | 50 | let clientId = localStorage.getItem("plex-client-id"); 51 | if (!clientId) { 52 | const uuid = uuidv4(); 53 | localStorage.setItem("plex-client-id", uuid); 54 | clientId = uuid; 55 | } 56 | 57 | const browser = Bowser.getParser(window.navigator.userAgent); 58 | this.plexHeaders = { 59 | Accept: "application/json", 60 | "X-Plex-Product": "Removarr", 61 | "X-Plex-Version": "Plex OAuth", 62 | "X-Plex-Client-Identifier": clientId, 63 | "X-Plex-Model": "Plex OAuth", 64 | "X-Plex-Platform": browser.getBrowserName(), 65 | "X-Plex-Platform-Version": browser.getBrowserVersion(), 66 | "X-Plex-Device": browser.getOSName(), 67 | "X-Plex-Device-Name": `${browser.getBrowserName()} (Removarr)`, 68 | "X-Plex-Device-Screen-Resolution": 69 | window.screen.width + "x" + window.screen.height, 70 | "X-Plex-Language": "en", 71 | }; 72 | } 73 | 74 | public async getPin(): Promise { 75 | if (!this.plexHeaders) { 76 | throw new Error( 77 | "You must initialize the plex headers clientside to login", 78 | ); 79 | } 80 | 81 | const response = await $fetch("https://plex.tv/api/v2/pins?strong=true", { 82 | method: "POST", 83 | headers: this.plexHeaders, 84 | }); 85 | 86 | this.pin = { id: response.id, code: response.code }; 87 | 88 | return this.pin; 89 | } 90 | 91 | public preparePopup(): void { 92 | this.openPopup({ title: "Plex Auth", w: 600, h: 700 }); 93 | } 94 | 95 | public async login(): Promise { 96 | this.initializeHeaders(); 97 | await this.getPin(); 98 | 99 | if (!this.plexHeaders || !this.pin) { 100 | throw new Error("Unable to call login if class is not initialized."); 101 | } 102 | 103 | const params = { 104 | clientID: this.plexHeaders["X-Plex-Client-Identifier"], 105 | "context[device][product]": this.plexHeaders["X-Plex-Product"], 106 | "context[device][version]": this.plexHeaders["X-Plex-Version"], 107 | "context[device][platform]": this.plexHeaders["X-Plex-Platform"], 108 | "context[device][platformVersion]": 109 | this.plexHeaders["X-Plex-Platform-Version"], 110 | "context[device][device]": this.plexHeaders["X-Plex-Device"], 111 | "context[device][deviceName]": this.plexHeaders["X-Plex-Device-Name"], 112 | "context[device][model]": this.plexHeaders["X-Plex-Model"], 113 | "context[device][screenResolution]": 114 | this.plexHeaders["X-Plex-Device-Screen-Resolution"], 115 | "context[device][layout]": "desktop", 116 | code: this.pin.code, 117 | }; 118 | 119 | if (this.popup) { 120 | this.popup.location.href = `https://app.plex.tv/auth/#!?${this.encodeData( 121 | params, 122 | )}`; 123 | } 124 | 125 | return this.pinPoll(); 126 | } 127 | 128 | private async pinPoll(): Promise { 129 | const executePoll = async ( 130 | resolve: (authToken: string) => void, 131 | reject: (e: Error) => void, 132 | ) => { 133 | try { 134 | if (!this.pin) { 135 | throw new Error("Unable to poll when pin is not initialized."); 136 | } 137 | 138 | const response = await $fetch( 139 | `https://plex.tv/api/v2/pins/${this.pin.id}`, 140 | { headers: this.plexHeaders }, 141 | ); 142 | 143 | if (response?.authToken) { 144 | this.authToken = response.authToken as string; 145 | this.closePopup(); 146 | resolve(this.authToken); 147 | } else if (!response?.authToken && !this.popup?.closed) { 148 | setTimeout(executePoll, 1000, resolve, reject); 149 | } else { 150 | reject(new Error("Popup closed without completing login")); 151 | } 152 | } catch (e) { 153 | console.log("error here : ", e); 154 | this.closePopup(); 155 | reject(e); 156 | } 157 | }; 158 | 159 | return new Promise(executePoll); 160 | } 161 | 162 | private closePopup(): void { 163 | this.popup?.close(); 164 | this.popup = undefined; 165 | } 166 | 167 | private openPopup({ 168 | title, 169 | w, 170 | h, 171 | }: { 172 | title: string; 173 | w: number; 174 | h: number; 175 | }): Window | void { 176 | if (!window) { 177 | throw new Error( 178 | "Window is undefined. Are you running this in the browser?", 179 | ); 180 | } 181 | // Fixes dual-screen position Most browsers Firefox 182 | const dualScreenLeft = 183 | window.screenLeft != undefined ? window.screenLeft : window.screenX; 184 | const dualScreenTop = 185 | window.screenTop != undefined ? window.screenTop : window.screenY; 186 | const width = window.innerWidth 187 | ? window.innerWidth 188 | : document.documentElement.clientWidth 189 | ? document.documentElement.clientWidth 190 | : screen.width; 191 | const height = window.innerHeight 192 | ? window.innerHeight 193 | : document.documentElement.clientHeight 194 | ? document.documentElement.clientHeight 195 | : screen.height; 196 | const left = width / 2 - w / 2 + dualScreenLeft; 197 | const top = height / 2 - h / 2 + dualScreenTop; 198 | 199 | //Set url to login/plex/loading so browser doesn't block popup 200 | const newWindow = window.open( 201 | "/login/plex/loading", 202 | title, 203 | "scrollbars=yes, width=" + 204 | w + 205 | ", height=" + 206 | h + 207 | ", top=" + 208 | top + 209 | ", left=" + 210 | left, 211 | ); 212 | if (newWindow) { 213 | newWindow.focus(); 214 | this.popup = newWindow; 215 | return this.popup; 216 | } 217 | } 218 | 219 | private encodeData(data: Record): string { 220 | return Object.keys(data) 221 | .map(function (key) { 222 | return [key, data[key]].map(encodeURIComponent).join("="); 223 | }) 224 | .join("&"); 225 | } 226 | } 227 | 228 | export default PlexOAuth; 229 | --------------------------------------------------------------------------------