├── .dockerignore ├── .editorconfig ├── .gitattributes ├── .github └── workflows │ └── publish-docker-image.yml ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── TrailerDownloader.csproj └── TrailerDownloader ├── .config └── dotnet-tools.json ├── .gitattributes ├── .gitignore ├── ClientApp ├── .browserslistrc ├── .editorconfig ├── .gitignore ├── .vscode │ └── launch.json ├── README.md ├── angular.json ├── e2e │ ├── protractor.conf.js │ ├── src │ │ ├── app.e2e-spec.ts │ │ └── app.po.ts │ └── tsconfig.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src │ ├── app │ │ ├── app-routing.module.ts │ │ ├── app.component.html │ │ ├── app.component.scss │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── guard │ │ │ └── page-guard.guard.ts │ │ ├── models │ │ │ ├── config.ts │ │ │ └── movie.ts │ │ ├── movie │ │ │ ├── movie.component.html │ │ │ ├── movie.component.scss │ │ │ └── movie.component.ts │ │ ├── movies │ │ │ ├── movies.component.html │ │ │ ├── movies.component.scss │ │ │ └── movies.component.ts │ │ ├── services │ │ │ ├── config.service.ts │ │ │ ├── movie.service.ts │ │ │ └── signalr.service.ts │ │ └── setup │ │ │ ├── setup.component.html │ │ │ ├── setup.component.scss │ │ │ └── setup.component.ts │ ├── assets │ │ ├── .gitkeep │ │ └── images │ │ │ └── default.png │ ├── environments │ │ ├── environment.prod.ts │ │ └── environment.ts │ ├── favicon.ico │ ├── index.html │ ├── main.ts │ ├── polyfills.ts │ ├── styles.scss │ └── test.ts ├── tsconfig.app.json ├── tsconfig.base.json ├── tsconfig.json ├── tsconfig.spec.json └── tslint.json ├── Controllers └── ConfigController.cs ├── Demo └── TrailerDownloader.gif ├── Models ├── Config.cs └── Movie.cs ├── Pages ├── Error.cshtml ├── Error.cshtml.cs └── _ViewImports.cshtml ├── Program.cs ├── Properties └── launchSettings.json ├── README.md ├── Repositories ├── ConfigRepository.cs ├── IConfigRepository.cs └── ITrailerRepository.cs ├── SignalRHubs └── MovieHub.cs ├── Startup.cs ├── TrailerDownloader.csproj ├── appsettings.Development.json ├── appsettings.json └── wwwroot └── favicon.ico /.dockerignore: -------------------------------------------------------------------------------- 1 | **/.classpath 2 | **/.dockerignore 3 | **/.env 4 | **/.git 5 | **/.gitignore 6 | **/.project 7 | **/.settings 8 | **/.toolstarget 9 | **/.vs 10 | **/.vscode 11 | **/*.*proj.user 12 | **/*.dbmdl 13 | **/*.jfm 14 | **/azds.yaml 15 | **/bin 16 | **/charts 17 | **/docker-compose* 18 | **/Dockerfile* 19 | **/node_modules 20 | **/npm-debug.log 21 | **/obj 22 | **/secrets.dev.yaml 23 | **/values.dev.yaml 24 | LICENSE 25 | README.md -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # Default severity for analyzer diagnostics with category 'Style' 4 | dotnet_analyzer_diagnostic.category-Style.severity = warning 5 | 6 | # IDE0052: Remove unread private members 7 | dotnet_diagnostic.IDE0052.severity = warning 8 | 9 | # IDE0005: Using directive is unnecessary. 10 | dotnet_diagnostic.IDE0005.severity = error 11 | 12 | # Default severity for analyzer diagnostics with category 'Performance' 13 | dotnet_analyzer_diagnostic.category-Performance.severity = none 14 | 15 | # IDE0058: Expression value is never used 16 | dotnet_diagnostic.IDE0058.severity = none 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/workflows/publish-docker-image.yml: -------------------------------------------------------------------------------- 1 | name: Publish Docker image 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | push_to_registry: 10 | name: Push Docker image to Docker Hub 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v4 15 | 16 | - name: Set up QEMU 17 | uses: docker/setup-qemu-action@v3 18 | 19 | - name: Set up Docker Buildx 20 | uses: docker/setup-buildx-action@v3 21 | 22 | - name: Log in to Docker Hub 23 | uses: docker/login-action@v3 24 | with: 25 | username: ${{ secrets.DOCKER_USERNAME }} 26 | password: ${{ secrets.DOCKER_PASSWORD }} 27 | 28 | - name: Build and push Docker image 29 | uses: docker/build-push-action@v6 30 | with: 31 | context: . 32 | push: true 33 | tags: taylorbobaylor/movie-trailer-downloader:latest 34 | platforms: linux/amd64 35 | cache-from: type=gha 36 | cache-to: type=gha,mode=max 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | *.angular/ 7 | 8 | # User-specific files 9 | *.rsuser 10 | *.suo 11 | *.user 12 | *.userosscache 13 | *.sln.docstates 14 | 15 | # User-specific files (MonoDevelop/Xamarin Studio) 16 | *.userprefs 17 | 18 | # Build results 19 | [Dd]ebug/ 20 | [Dd]ebugPublic/ 21 | [Rr]elease/ 22 | [Rr]eleases/ 23 | x64/ 24 | x86/ 25 | [Aa][Rr][Mm]/ 26 | [Aa][Rr][Mm]64/ 27 | bld/ 28 | [Bb]in/ 29 | [Oo]bj/ 30 | [Ll]og/ 31 | 32 | # Visual Studio 2015/2017 cache/options directory 33 | .vs/ 34 | # Uncomment if you have tasks that create the project's static files in wwwroot 35 | #wwwroot/ 36 | 37 | # Visual Studio 2017 auto generated files 38 | Generated\ Files/ 39 | 40 | # MSTest test Results 41 | [Tt]est[Rr]esult*/ 42 | [Bb]uild[Ll]og.* 43 | 44 | # NUNIT 45 | *.VisualState.xml 46 | TestResult.xml 47 | 48 | # Build Results of an ATL Project 49 | [Dd]ebugPS/ 50 | [Rr]eleasePS/ 51 | dlldata.c 52 | 53 | # Benchmark Results 54 | BenchmarkDotNet.Artifacts/ 55 | 56 | # .NET Core 57 | project.lock.json 58 | project.fragment.lock.json 59 | artifacts/ 60 | 61 | # StyleCop 62 | StyleCopReport.xml 63 | 64 | # Files built by Visual Studio 65 | *_i.c 66 | *_p.c 67 | *_h.h 68 | *.ilk 69 | *.meta 70 | *.obj 71 | *.iobj 72 | *.pch 73 | *.pdb 74 | *.ipdb 75 | *.pgc 76 | *.pgd 77 | *.rsp 78 | *.sbr 79 | *.tlb 80 | *.tli 81 | *.tlh 82 | *.tmp 83 | *.tmp_proj 84 | *_wpftmp.csproj 85 | *.log 86 | *.vspscc 87 | *.vssscc 88 | .builds 89 | *.pidb 90 | *.svclog 91 | *.scc 92 | 93 | # Chutzpah Test files 94 | _Chutzpah* 95 | 96 | # Visual C++ cache files 97 | ipch/ 98 | *.aps 99 | *.ncb 100 | *.opendb 101 | *.opensdf 102 | *.sdf 103 | *.cachefile 104 | *.VC.db 105 | *.VC.VC.opendb 106 | 107 | # Visual Studio profiler 108 | *.psess 109 | *.vsp 110 | *.vspx 111 | *.sap 112 | 113 | # Visual Studio Trace Files 114 | *.e2e 115 | 116 | # TFS 2012 Local Workspace 117 | $tf/ 118 | 119 | # Guidance Automation Toolkit 120 | *.gpState 121 | 122 | # ReSharper is a .NET coding add-in 123 | _ReSharper*/ 124 | *.[Rr]e[Ss]harper 125 | *.DotSettings.user 126 | 127 | # JustCode is a .NET coding add-in 128 | .JustCode 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # The packages folder can be ignored because of Package Restore 188 | **/[Pp]ackages/* 189 | # except build/, which is used as an MSBuild target. 190 | !**/[Pp]ackages/build/ 191 | # Uncomment if necessary however generally it will be regenerated when needed 192 | #!**/[Pp]ackages/repositories.config 193 | # NuGet v3's project.json files produces more ignorable files 194 | *.nuget.props 195 | *.nuget.targets 196 | 197 | # Microsoft Azure Build Output 198 | csx/ 199 | *.build.csdef 200 | 201 | # Microsoft Azure Emulator 202 | ecf/ 203 | rcf/ 204 | 205 | # Windows Store app package directories and files 206 | AppPackages/ 207 | BundleArtifacts/ 208 | Package.StoreAssociation.xml 209 | _pkginfo.txt 210 | *.appx 211 | 212 | # Visual Studio cache files 213 | # files ending in .cache can be ignored 214 | *.[Cc]ache 215 | # but keep track of directories ending in .cache 216 | !?*.[Cc]ache/ 217 | 218 | # Others 219 | ClientBin/ 220 | ~$* 221 | *~ 222 | *.dbmdl 223 | *.dbproj.schemaview 224 | *.jfm 225 | *.pfx 226 | *.publishsettings 227 | orleans.codegen.cs 228 | 229 | # Including strong name files can present a security risk 230 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 231 | #*.snk 232 | 233 | # Since there are multiple workflows, uncomment next line to ignore bower_components 234 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 235 | #bower_components/ 236 | 237 | # RIA/Silverlight projects 238 | Generated_Code/ 239 | 240 | # Backup & report files from converting an old project file 241 | # to a newer Visual Studio version. Backup files are not needed, 242 | # because we have git ;-) 243 | _UpgradeReport_Files/ 244 | Backup*/ 245 | UpgradeLog*.XML 246 | UpgradeLog*.htm 247 | ServiceFabricBackup/ 248 | *.rptproj.bak 249 | 250 | # SQL Server files 251 | *.mdf 252 | *.ldf 253 | *.ndf 254 | 255 | # Business Intelligence projects 256 | *.rdl.data 257 | *.bim.layout 258 | *.bim_*.settings 259 | *.rptproj.rsuser 260 | *- Backup*.rdl 261 | 262 | # Microsoft Fakes 263 | FakesAssemblies/ 264 | 265 | # GhostDoc plugin setting file 266 | *.GhostDoc.xml 267 | 268 | # Node.js Tools for Visual Studio 269 | .ntvs_analysis.dat 270 | node_modules/ 271 | 272 | # Visual Studio 6 build log 273 | *.plg 274 | 275 | # Visual Studio 6 workspace options file 276 | *.opt 277 | 278 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 279 | *.vbw 280 | 281 | # Visual Studio LightSwitch build output 282 | **/*.HTMLClient/GeneratedArtifacts 283 | **/*.DesktopClient/GeneratedArtifacts 284 | **/*.DesktopClient/ModelManifest.xml 285 | **/*.Server/GeneratedArtifacts 286 | **/*.Server/ModelManifest.xml 287 | _Pvt_Extensions 288 | 289 | # Paket dependency manager 290 | .paket/paket.exe 291 | paket-files/ 292 | 293 | # FAKE - F# Make 294 | .fake/ 295 | 296 | # JetBrains Rider 297 | .idea/ 298 | *.sln.iml 299 | 300 | # CodeRush personal settings 301 | .cr/personal 302 | 303 | # Python Tools for Visual Studio (PTVS) 304 | __pycache__/ 305 | *.pyc 306 | 307 | # Cake - Uncomment if you are using it 308 | # tools/** 309 | # !tools/packages.config 310 | 311 | # Tabs Studio 312 | *.tss 313 | 314 | # Telerik's JustMock configuration file 315 | *.jmconfig 316 | 317 | # BizTalk build output 318 | *.btp.cs 319 | *.btm.cs 320 | *.odx.cs 321 | *.xsd.cs 322 | 323 | # OpenCover UI analysis results 324 | OpenCover/ 325 | 326 | # Azure Stream Analytics local run output 327 | ASALocalRun/ 328 | 329 | # MSBuild Binary and Structured Log 330 | *.binlog 331 | 332 | # NVidia Nsight GPU debugger configuration file 333 | *.nvuser 334 | 335 | # MFractors (Xamarin productivity tool) working folder 336 | .mfractor/ 337 | 338 | # Local History for Visual Studio 339 | .localhistory/ 340 | 341 | # BeatPulse healthcheck temp database 342 | healthchecksdb 343 | TrailerDownloader/config.json 344 | 345 | .DS_STORE 346 | 347 | /dist/ 348 | /bazel-out 349 | /integration/bazel/bazel-* 350 | *.log 351 | node_modules 352 | 353 | # CircleCI temporary file for cache key computation. 354 | # See `save_month_to_file` in `.circleci/config.yml`. 355 | month.txt 356 | 357 | # Include when developing application packages. 358 | pubspec.lock 359 | .c9 360 | .idea/ 361 | .devcontainer/* 362 | !.devcontainer/README.md 363 | !.devcontainer/recommended-devcontainer.json 364 | !.devcontainer/recommended-Dockerfile 365 | .settings/ 366 | .vscode/launch.json 367 | .vscode/settings.json 368 | .vscode/tasks.json 369 | *.swo 370 | *.swp 371 | modules/.settings 372 | modules/.vscode 373 | .vimrc 374 | .nvimrc 375 | 376 | # Don't check in secret files 377 | *secret.js 378 | 379 | # Ignore npm/yarn debug log 380 | npm-debug.log 381 | yarn-error.log 382 | 383 | # build-analytics 384 | .build-analytics 385 | 386 | # rollup-test output 387 | /modules/rollup-test/dist/ 388 | 389 | # User specific bazel settings 390 | .bazelrc.user 391 | 392 | # User specific ng-dev settings 393 | .ng-dev.user* 394 | 395 | .notes.md 396 | baseline.json 397 | 398 | # Ignore .history for the xyz.local-history VSCode extension 399 | .history 400 | 401 | # Husky 402 | .husky/_ 403 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base 2 | 3 | WORKDIR /app 4 | EXPOSE 80 5 | 6 | FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build 7 | 8 | # Install Node.js and ffmpeg 9 | # Note: Consider using a specific version of Node.js for better stability and compatibility 10 | RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ 11 | && apt-get install -y \ 12 | nodejs \ 13 | ffmpeg \ 14 | && rm -rf /var/lib/apt/lists/* 15 | 16 | ARG BUILD_CONFIGURATION=Release 17 | WORKDIR /src 18 | COPY ["TrailerDownloader/TrailerDownloader.csproj", "TrailerDownloader/"] 19 | RUN dotnet restore "TrailerDownloader/TrailerDownloader.csproj" 20 | COPY . . 21 | WORKDIR "/src/TrailerDownloader" 22 | RUN dotnet build "TrailerDownloader.csproj" -c $BUILD_CONFIGURATION -o /app/build 23 | 24 | FROM build AS publish 25 | ARG BUILD_CONFIGURATION=Release 26 | RUN dotnet publish "TrailerDownloader.csproj" -c $BUILD_CONFIGURATION -o /app/build 27 | 28 | FROM base AS final 29 | WORKDIR /app 30 | COPY --from=publish /app/build . 31 | ENTRYPOINT ["dotnet", "TrailerDownloader.dll"] 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 | # TrailerDownloader 2 | 3 | ## Description 4 | Downloads all missing trailers for movies in your Plex library. When it downloads, it will place the trailer in the same folder the movie is in with the name {MovieTitle}-trailer. 5 | 6 | ## Installation 7 | 8 | ### docker cli 9 | ```bash 10 | docker run -d \ 11 | --name=movie-trailer-downloader \ 12 | -p 6767:8080 \ 13 | -v /path/to/movies:/movies \ 14 | taylorbobaylor/movie-trailer-downloader 15 | ``` 16 | 17 | [Docker Hub Repo](https://hub.docker.com/repository/docker/taylorbobaylor/movie-trailer-downloader) 18 | 19 | ### Windows 20 | 1. Download the latest TrailerDownloaderWindows.zip [here](https://github.com/taylorbobaylor/TrailerDownloader/releases/latest) 21 | 2. Extract the zip to your preferred directory. 22 | 3. Run TrailerDownloader.exe 23 | 24 | ## Demo 25 | ![til](./TrailerDownloader/Demo/TrailerDownloader.gif) 26 | 27 | ## Structure 28 | This app expects your movies to be in a specific structure. If your movies do not match the format below, you will not be able to use this. 29 | 30 | -Movies 31 | ---Movie Title 1 (2014) 32 | -----Movie Title 1 (2014).mp4 33 | ---Movie Title 2 (2009) 34 | -----Movie Title 2 (2009).mkv 35 | 36 | ## Donate 37 | 38 | I did this for fun and a learning experience but feel free to buy me a cup of coffee so I can continue to make this app awesome! 39 | 40 | [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZRP9ZGW3RDDRN) 41 | 42 | Hopefully this will help someone and enjoy! 43 | -------------------------------------------------------------------------------- /TrailerDownloader.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /TrailerDownloader/.config/dotnet-tools.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "isRoot": true, 4 | "tools": { 5 | "dotnet-ef": { 6 | "version": "5.0.1", 7 | "commands": [ 8 | "dotnet-ef" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /TrailerDownloader/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /TrailerDownloader/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # JustCode is a .NET coding add-in 131 | .JustCode 132 | 133 | # TeamCity is a build add-in 134 | _TeamCity* 135 | 136 | # DotCover is a Code Coverage Tool 137 | *.dotCover 138 | 139 | # AxoCover is a Code Coverage Tool 140 | .axoCover/* 141 | !.axoCover/settings.json 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major version 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 9-11 # For IE 9-11 support, remove 'not'. 18 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | # Only exists if Bazel was run 8 | /bazel-out 9 | 10 | # dependencies 11 | /node_modules 12 | 13 | # profiling files 14 | chrome-profiler-events*.json 15 | speed-measure-plugin*.json 16 | 17 | # IDEs and editors 18 | /.idea 19 | .project 20 | .classpath 21 | .c9/ 22 | *.launch 23 | .settings/ 24 | *.sublime-workspace 25 | 26 | # IDE - VSCode 27 | .vscode/* 28 | !.vscode/settings.json 29 | !.vscode/tasks.json 30 | !.vscode/launch.json 31 | !.vscode/extensions.json 32 | .history/* 33 | 34 | # misc 35 | /.sass-cache 36 | /connect.lock 37 | /coverage 38 | /libpeerconnection.log 39 | npm-debug.log 40 | yarn-error.log 41 | testem.log 42 | /typings 43 | 44 | # System Files 45 | .DS_Store 46 | Thumbs.db 47 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | 8 | { 9 | "type": "chrome", 10 | "request": "launch", 11 | "name": "Launch Chrome against localhost", 12 | "url": "http://localhost:4200", 13 | "webRoot": "${workspaceFolder}" 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/README.md: -------------------------------------------------------------------------------- 1 | # TrailerDownloaderFrontend 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 10.0.0. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 28 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "TrailerDownloader-Frontend": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:component": { 10 | "style": "scss" 11 | } 12 | }, 13 | "root": "", 14 | "sourceRoot": "src", 15 | "prefix": "app", 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "outputPath": "dist", 21 | "index": "src/index.html", 22 | "main": "src/main.ts", 23 | "polyfills": "src/polyfills.ts", 24 | "tsConfig": "tsconfig.app.json", 25 | "aot": true, 26 | "assets": [ 27 | "src/favicon.ico", 28 | "src/assets" 29 | ], 30 | "styles": [ 31 | "src/styles.scss", 32 | "node_modules/ngx-toastr/toastr.css" 33 | ], 34 | "scripts": [] 35 | }, 36 | "configurations": { 37 | "production": { 38 | "fileReplacements": [ 39 | { 40 | "replace": "src/environments/environment.ts", 41 | "with": "src/environments/environment.prod.ts" 42 | } 43 | ], 44 | "optimization": true, 45 | "outputHashing": "all", 46 | "sourceMap": false, 47 | "extractCss": true, 48 | "namedChunks": false, 49 | "extractLicenses": true, 50 | "vendorChunk": false, 51 | "buildOptimizer": true, 52 | "budgets": [ 53 | { 54 | "type": "initial", 55 | "maximumWarning": "2mb", 56 | "maximumError": "5mb" 57 | }, 58 | { 59 | "type": "anyComponentStyle", 60 | "maximumWarning": "6kb", 61 | "maximumError": "10kb" 62 | } 63 | ] 64 | } 65 | } 66 | }, 67 | "serve": { 68 | "builder": "@angular-devkit/build-angular:dev-server", 69 | "options": { 70 | "browserTarget": "TrailerDownloader-Frontend:build" 71 | }, 72 | "configurations": { 73 | "production": { 74 | "browserTarget": "TrailerDownloader-Frontend:build:production" 75 | } 76 | } 77 | }, 78 | "extract-i18n": { 79 | "builder": "@angular-devkit/build-angular:extract-i18n", 80 | "options": { 81 | "browserTarget": "TrailerDownloader-Frontend:build" 82 | } 83 | }, 84 | "test": { 85 | "builder": "@angular-devkit/build-angular:karma", 86 | "options": { 87 | "main": "src/test.ts", 88 | "polyfills": "src/polyfills.ts", 89 | "tsConfig": "tsconfig.spec.json", 90 | "karmaConfig": "karma.conf.js", 91 | "assets": [ 92 | "src/favicon.ico", 93 | "src/assets" 94 | ], 95 | "styles": [ 96 | "src/styles.scss" 97 | ], 98 | "scripts": [] 99 | } 100 | }, 101 | "lint": { 102 | "builder": "@angular-devkit/build-angular:tslint", 103 | "options": { 104 | "tsConfig": [ 105 | "tsconfig.app.json", 106 | "tsconfig.spec.json", 107 | "e2e/tsconfig.json" 108 | ], 109 | "exclude": [ 110 | "**/node_modules/**" 111 | ] 112 | } 113 | }, 114 | "e2e": { 115 | "builder": "@angular-devkit/build-angular:protractor", 116 | "options": { 117 | "protractorConfig": "e2e/protractor.conf.js", 118 | "devServerTarget": "TrailerDownloader-Frontend:serve" 119 | }, 120 | "configurations": { 121 | "production": { 122 | "devServerTarget": "TrailerDownloader-Frontend:serve:production" 123 | } 124 | } 125 | } 126 | } 127 | }}, 128 | "defaultProject": "TrailerDownloader-Frontend", 129 | "cli": { 130 | "analytics": false 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // @ts-check 2 | // Protractor configuration file, see link for more information 3 | // https://github.com/angular/protractor/blob/master/lib/config.ts 4 | 5 | const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter'); 6 | 7 | /** 8 | * @type { import("protractor").Config } 9 | */ 10 | exports.config = { 11 | allScriptsTimeout: 11000, 12 | specs: [ 13 | './src/**/*.e2e-spec.ts' 14 | ], 15 | capabilities: { 16 | browserName: 'chrome' 17 | }, 18 | directConnect: true, 19 | baseUrl: 'http://localhost:4200/', 20 | framework: 'jasmine', 21 | jasmineNodeOpts: { 22 | showColors: true, 23 | defaultTimeoutInterval: 30000, 24 | print: function() {} 25 | }, 26 | onPrepare() { 27 | require('ts-node').register({ 28 | project: require('path').join(__dirname, './tsconfig.json') 29 | }); 30 | jasmine.getEnv().addReporter(new SpecReporter({ 31 | spec: { 32 | displayStacktrace: StacktraceOption.PRETTY 33 | } 34 | })); 35 | } 36 | }; -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('TrailerDownloader-Frontend app is running!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | } as logging.Entry)); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo(): Promise { 5 | return browser.get(browser.baseUrl) as Promise; 6 | } 7 | 8 | getTitleText(): Promise { 9 | return element(by.css('app-root .content span')).getText() as Promise; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/e2e/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "../tsconfig.base.json", 4 | "compilerOptions": { 5 | "outDir": "../out-tsc/e2e", 6 | "module": "commonjs", 7 | "target": "es2018", 8 | "types": [ 9 | "jasmine", 10 | "jasminewd2", 11 | "node" 12 | ] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, './coverage/TrailerDownloader-Frontend'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false, 30 | restartOnFileChange: true 31 | }); 32 | }; 33 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "trailer-downloader-frontend", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "echo starting... && ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "^15.2.8", 15 | "@angular/common": "~15.2.8", 16 | "@angular/compiler": "~15.2.8", 17 | "@angular/core": "~15.2.8", 18 | "@angular/forms": "~15.2.8", 19 | "@angular/platform-browser": "~15.2.8", 20 | "@angular/platform-browser-dynamic": "~15.2.8", 21 | "@angular/router": "~15.2.8", 22 | "@microsoft/signalr": "^7.0.5", 23 | "ngx-toastr": "^16.1.1", 24 | "rxjs": "~7.8.1", 25 | "toastr": "^2.1.4", 26 | "tslib": "^2.5.0", 27 | "uuid": "^9.0.0", 28 | "zone.js": "~0.13.0" 29 | }, 30 | "devDependencies": { 31 | "@angular-devkit/build-angular": "^15.2.7", 32 | "@angular/cli": "^15.2.7", 33 | "@angular/compiler-cli": "~15.2.8", 34 | "@types/jasmine": "~4.3.1", 35 | "@types/jasminewd2": "~2.0.10", 36 | "@types/node": "^18.16.3", 37 | "codelyzer": "^6.0.2", 38 | "jasmine-core": "~4.6.0", 39 | "jasmine-spec-reporter": "~7.0.0", 40 | "karma": "~6.4.2", 41 | "karma-chrome-launcher": "~3.2.0", 42 | "karma-coverage-istanbul-reporter": "~3.0.3", 43 | "karma-jasmine": "~5.1.0", 44 | "karma-jasmine-html-reporter": "^2.0.0", 45 | "protractor": "^7.0.0", 46 | "ts-node": "~10.9.1", 47 | "tslint": "~6.1.0", 48 | "typescript": ">=4.8.2 <5.0" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { MoviesComponent } from './movies/movies.component'; 4 | import { SetupComponent } from './setup/setup.component'; 5 | import { PageGuardGuard } from './guard/page-guard.guard'; 6 | 7 | 8 | const routes: Routes = [ 9 | { 10 | path: '', 11 | redirectTo: 'movies', 12 | pathMatch: 'full' 13 | }, 14 | { 15 | path: 'setup', 16 | component: SetupComponent 17 | }, 18 | { 19 | path: 'movies', 20 | component: MoviesComponent, 21 | canActivate: [PageGuardGuard] 22 | } 23 | ]; 24 | 25 | @NgModule({ 26 | imports: [RouterModule.forRoot(routes)], 27 | exports: [RouterModule] 28 | }) 29 | export class AppRoutingModule { } 30 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taylorbobaylor/TrailerDownloader/f77d78eeedb57ca07468ec7a6908983d4781d5dc/TrailerDownloader/ClientApp/src/app/app.component.scss -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | TestBed.configureTestingModule({ 8 | imports: [ 9 | RouterTestingModule 10 | ], 11 | declarations: [ 12 | AppComponent 13 | ], 14 | }).compileComponents(); 15 | })); 16 | 17 | it('should create the app', () => { 18 | const fixture = TestBed.createComponent(AppComponent); 19 | const app = fixture.componentInstance; 20 | expect(app).toBeTruthy(); 21 | }); 22 | 23 | it(`should have as title 'TrailerDownloader-Frontend'`, () => { 24 | const fixture = TestBed.createComponent(AppComponent); 25 | const app = fixture.componentInstance; 26 | expect(app.title).toEqual('TrailerDownloader-Frontend'); 27 | }); 28 | 29 | it('should render title', () => { 30 | const fixture = TestBed.createComponent(AppComponent); 31 | fixture.detectChanges(); 32 | const compiled = fixture.nativeElement; 33 | expect(compiled.querySelector('.content span').textContent).toContain('TrailerDownloader-Frontend app is running!'); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.scss'] 7 | }) 8 | export class AppComponent { 9 | title = 'TrailerDownloader-Frontend'; 10 | } 11 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | import { ConfigService } from "./services/config.service"; 4 | import { SignalrService } from "./services/signalr.service"; 5 | 6 | import { AppRoutingModule } from './app-routing.module'; 7 | import { AppComponent } from './app.component'; 8 | import { HashLocationStrategy, LocationStrategy } from '@angular/common'; 9 | import { SetupComponent } from './setup/setup.component'; 10 | import { MoviesComponent } from './movies/movies.component'; 11 | import { HttpClientModule } from '@angular/common/http'; 12 | import { FormsModule } from '@angular/forms'; 13 | import { MovieComponent } from './movie/movie.component'; 14 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 15 | import { ToastrModule } from 'ngx-toastr'; 16 | 17 | @NgModule({ 18 | declarations: [ 19 | AppComponent, 20 | SetupComponent, 21 | MoviesComponent, 22 | MovieComponent 23 | ], 24 | imports: [ 25 | BrowserModule, 26 | AppRoutingModule, 27 | HttpClientModule, 28 | FormsModule, 29 | BrowserAnimationsModule, 30 | ToastrModule.forRoot({ 31 | timeOut: 2500 32 | }) 33 | ], 34 | providers: [ 35 | ConfigService, 36 | SignalrService 37 | ], 38 | bootstrap: [AppComponent] 39 | }) 40 | export class AppModule { } 41 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/guard/page-guard.guard.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router'; 3 | import { Observable } from 'rxjs'; 4 | import { Config } from '../models/config'; 5 | import { ConfigService } from '../services/config.service'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class PageGuardGuard implements CanActivate { 11 | 12 | config: Config; 13 | test: any = {}; 14 | 15 | constructor(private router: Router, private configService: ConfigService) {} 16 | 17 | canActivate( 18 | next: ActivatedRouteSnapshot, 19 | state: RouterStateSnapshot): Observable | Promise | boolean | UrlTree { 20 | 21 | return this.configService.getConfig().toPromise().then(res => { 22 | if (res) { 23 | return true; 24 | } 25 | else { 26 | console.log('No config file so redirecting to setup page.'); 27 | this.router.navigate(['setup']); 28 | return false; 29 | } 30 | }); 31 | 32 | // var x = this.configService.getConfig().subscribe(data => { 33 | // this.config = data; 34 | // // console.log(this.config); 35 | // return data; 36 | // }); 37 | 38 | // if (this.getConfig()) { 39 | // return true; 40 | // } 41 | // else { 42 | // this.router.navigate(['setup']); 43 | // return false; 44 | // } 45 | 46 | // if (this.configService.doesConfigExist()) { 47 | // return true; 48 | // } 49 | // else { 50 | // this.router.navigate(['setup']); 51 | // return false; 52 | // } 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/models/config.ts: -------------------------------------------------------------------------------- 1 | export interface Config { 2 | tmdbKey: string; 3 | mediaDirectory: string; 4 | } 5 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/models/movie.ts: -------------------------------------------------------------------------------- 1 | export interface Movie { 2 | posterPath: string, 3 | trailerURL: string, 4 | id: number, 5 | filePath: string, 6 | title: string, 7 | year: string, 8 | trailerExists: boolean 9 | } 10 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/movie/movie.component.html: -------------------------------------------------------------------------------- 1 |
2 | 8 | 9 |
10 |
{{ movieInfo.title }}
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 |
26 |
27 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/movie/movie.component.scss: -------------------------------------------------------------------------------- 1 | img { 2 | float: center; 3 | width: 100%; 4 | height: 21em; 5 | object-fit: cover; 6 | } 7 | 8 | .card-title { 9 | white-space: nowrap; 10 | overflow: hidden; 11 | text-overflow: ellipsis; 12 | } 13 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/movie/movie.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, OnInit } from '@angular/core'; 2 | import { Movie } from "../models/movie"; 3 | import { SignalrService } from '../services/signalr.service'; 4 | 5 | @Component({ 6 | selector: 'app-movie', 7 | templateUrl: './movie.component.html', 8 | styleUrls: ['./movie.component.scss'] 9 | }) 10 | export class MovieComponent implements OnInit { 11 | 12 | @Input() movieInfo: Movie; 13 | 14 | constructor(private signalrService: SignalrService) { } 15 | 16 | ngOnInit(): void { 17 | } 18 | 19 | addTrailerToDownloadArray(movie: Movie) { 20 | if (!this.signalrService.trailersToDownload.some(item => item.filePath === movie.filePath)) { 21 | this.signalrService.trailersToDownload.push(movie); 22 | } 23 | else { 24 | this.signalrService.trailersToDownload = this.signalrService.trailersToDownload.filter(item => item.filePath !== movie.filePath); 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/movies/movies.component.html: -------------------------------------------------------------------------------- 1 |
2 | 5 | 6 | 7 | 8 |
9 |
10 | 11 |
12 |
13 | 14 | 15 | 18 | 19 | 20 | 39 | 40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/movies/movies.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taylorbobaylor/TrailerDownloader/f77d78eeedb57ca07468ec7a6908983d4781d5dc/TrailerDownloader/ClientApp/src/app/movies/movies.component.scss -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/movies/movies.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { ToastrService } from 'ngx-toastr'; 3 | import { Movie } from '../models/movie'; 4 | import { SignalrService } from '../services/signalr.service'; 5 | 6 | @Component({ 7 | selector: 'app-movies', 8 | templateUrl: './movies.component.html', 9 | styleUrls: ['./movies.component.scss'] 10 | }) 11 | export class MoviesComponent implements OnInit { 12 | 13 | constructor(private toastr: ToastrService, 14 | public signalrService: SignalrService) {} 15 | 16 | ngOnInit(): void { 17 | this.signalrService.startConnection(); 18 | this.signalrService.downloadAllTrailersListener(); 19 | this.signalrService.deleteAllTrailersListener(); 20 | } 21 | 22 | downloadAllTrailers(movieList: Array) { 23 | this.toastr.success('Starting download of all trailers', 'Success!'); 24 | this.signalrService.downloadAllTrailers(movieList); 25 | } 26 | 27 | deleteAllTrailers(movieList: Array) { 28 | this.toastr.warning('Deleting all trailers'); 29 | this.signalrService.deleteAllTrailers(movieList); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/services/config.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient } from "@angular/common/http"; 3 | import { NgForm } from '@angular/forms'; 4 | 5 | @Injectable({ 6 | providedIn: 'root' 7 | }) 8 | export class ConfigService { 9 | 10 | configEndpoint: string = window.location.origin + "/api/config"; 11 | 12 | constructor(private http: HttpClient) { } 13 | 14 | getConfig() { 15 | return this.http.get(this.configEndpoint); 16 | } 17 | 18 | saveConfig(form: NgForm) { 19 | return this.http.post(this.configEndpoint, form); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/services/movie.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient } from "@angular/common/http"; 3 | 4 | @Injectable({ 5 | providedIn: 'root' 6 | }) 7 | export class MovieService { 8 | 9 | constructor(private http: HttpClient) { } 10 | 11 | getAllMovies() { 12 | return this.http.get(window.location.origin + '/api/trailer'); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/services/signalr.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import * as signalR from "@microsoft/signalr"; 3 | import { ToastrService } from 'ngx-toastr'; 4 | import { Movie } from "../models/movie"; 5 | 6 | @Injectable({ 7 | providedIn: 'root' 8 | }) 9 | export class SignalrService { 10 | 11 | hubConnection: signalR.HubConnection; 12 | movieList: Array = []; 13 | trailersToDownload: Array = []; 14 | 15 | allMoviesLoaded: boolean = false; 16 | 17 | constructor(private toastr: ToastrService) { } 18 | 19 | startConnection = () => { 20 | this.hubConnection = new signalR.HubConnectionBuilder() 21 | .withUrl(window.location.origin + '/moviehub') 22 | .build(); 23 | 24 | this.hubConnection.start().then(() => { 25 | console.log('Connection started'); 26 | this.completedAllMoviesInfoListener(); 27 | this.getAllMoviesInfoListener(); 28 | this.doneDownloadingAllTrailersListener(); 29 | this.getAllMoviesInfo(); 30 | }).catch(err => { 31 | console.log('Error starting connection: ' + err); 32 | }); 33 | } 34 | 35 | downloadAllTrailersListener = () => { 36 | this.hubConnection.on('downloadAllTrailers', (data: Movie) => { 37 | if (data.trailerExists) { 38 | let indexOfMovieInList = this.movieList.findIndex(x => x.title === data.title); 39 | this.movieList[indexOfMovieInList] = data; 40 | this.toastr.success(`Done downloading trailer for ${data.title}`, 'Success!'); 41 | } 42 | else { 43 | this.toastr.error(`Issues downloading trailer for ${data.title}, please check the logs`, 'Error'); 44 | } 45 | }); 46 | } 47 | 48 | downloadAllTrailers(movieList: Array) { 49 | this.hubConnection.invoke('downloadAllTrailers', movieList).catch(err => console.log(err)); 50 | } 51 | 52 | deleteAllTrailersListener = () => { 53 | this.hubConnection.on('deleteAllTrailers', (data: Movie) => { 54 | let indexOfMovieInList = this.movieList.findIndex(x => x.title === data.title); 55 | this.movieList[indexOfMovieInList] = data; 56 | }); 57 | } 58 | 59 | deleteAllTrailers(movieList: Array) { 60 | this.hubConnection.invoke('deleteAllTrailers', movieList); 61 | } 62 | 63 | private getAllMoviesInfoListener = () => { 64 | this.hubConnection.on('getAllMoviesInfo', (data: Movie) => { 65 | this.movieList.push(data); 66 | this.movieList.sort((a, b) => a.title.localeCompare(b.title)); 67 | }); 68 | } 69 | 70 | private getAllMoviesInfo() { 71 | this.hubConnection.invoke('getAllMoviesInfo').catch(err => console.log(err)); 72 | } 73 | 74 | private completedAllMoviesInfoListener = () => { 75 | this.hubConnection.on('completedAllMoviesInfo', data => { 76 | console.log(`Retrieved info for ${data} movies in your library`); 77 | this.toastr.success(`Retrieved info for ${data} movies in your library`, 'Success!'); 78 | this.allMoviesLoaded = true; 79 | }); 80 | } 81 | 82 | private doneDownloadingAllTrailersListener = () => { 83 | this.hubConnection.on('doneDownloadingAllTrailersListener', data => { 84 | if (data === true) { 85 | this.trailersToDownload = []; 86 | console.log('Successfully downloaded all missing trailers!'); 87 | this.toastr.success('Done downloading all missing trailers', 'Success!'); 88 | } 89 | }); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/setup/setup.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 | 6 |
7 | 8 |
9 | 10 | 11 |
12 | 13 |
14 |
15 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/setup/setup.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taylorbobaylor/TrailerDownloader/f77d78eeedb57ca07468ec7a6908983d4781d5dc/TrailerDownloader/ClientApp/src/app/setup/setup.component.scss -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/app/setup/setup.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { NgForm } from '@angular/forms'; 3 | import { Router } from '@angular/router'; 4 | import { ToastrService } from 'ngx-toastr'; 5 | import { ConfigService } from '../services/config.service'; 6 | 7 | @Component({ 8 | selector: 'app-setup', 9 | templateUrl: './setup.component.html', 10 | styleUrls: ['./setup.component.scss'] 11 | }) 12 | export class SetupComponent implements OnInit { 13 | 14 | constructor(private configService: ConfigService, private router: Router, 15 | private toastr: ToastrService) { } 16 | 17 | ngOnInit(): void { 18 | } 19 | 20 | onSubmit(form: NgForm) { 21 | if (form.valid) { 22 | this.configService.saveConfig(form.value).subscribe(res => { 23 | if (res === true) { 24 | this.toastr.success('Configuration saved', 'Success!'); 25 | this.router.navigate(['movies']); 26 | } 27 | else { 28 | console.log('Media directory path does not exist... Please try again.'); 29 | this.toastr.error('Media directory path does not exist... Please try again', 'Error'); 30 | } 31 | }, err => { 32 | console.log(err); 33 | }); 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taylorbobaylor/TrailerDownloader/f77d78eeedb57ca07468ec7a6908983d4781d5dc/TrailerDownloader/ClientApp/src/assets/.gitkeep -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/assets/images/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taylorbobaylor/TrailerDownloader/f77d78eeedb57ca07468ec7a6908983d4781d5dc/TrailerDownloader/ClientApp/src/assets/images/default.png -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taylorbobaylor/TrailerDownloader/f77d78eeedb57ca07468ec7a6908983d4781d5dc/TrailerDownloader/ClientApp/src/favicon.ico -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Trailer Downloader 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/styles.scss: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | keys(): string[]; 13 | (id: string): T; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting() 21 | ); 22 | // Then we find all the tests. 23 | const context = require.context('./', true, /\.spec\.ts$/); 24 | // And load the modules. 25 | context.keys().map(context); 26 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.base.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/tsconfig.base.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "sourceMap": true, 8 | "declaration": false, 9 | "downlevelIteration": true, 10 | "experimentalDecorators": true, 11 | "moduleResolution": "node", 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "module": "es2020", 15 | "lib": [ 16 | "es2018", 17 | "dom" 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* 2 | This is a "Solution Style" tsconfig.json file, and is used by editors and TypeScript’s language server to improve development experience. 3 | It is not intended to be used to perform a compilation. 4 | 5 | To learn more about this file see: https://angular.io/config/solution-tsconfig. 6 | */ 7 | { 8 | "files": [], 9 | "references": [ 10 | { 11 | "path": "./tsconfig.app.json" 12 | }, 13 | { 14 | "path": "./tsconfig.spec.json" 15 | }, 16 | { 17 | "path": "./e2e/tsconfig.json" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.base.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /TrailerDownloader/ClientApp/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "tslint:recommended", 3 | "rules": { 4 | "align": { 5 | "options": [ 6 | "parameters", 7 | "statements" 8 | ] 9 | }, 10 | "array-type": false, 11 | "arrow-return-shorthand": true, 12 | "curly": true, 13 | "deprecation": { 14 | "severity": "warning" 15 | }, 16 | "component-class-suffix": true, 17 | "contextual-lifecycle": true, 18 | "directive-class-suffix": true, 19 | "directive-selector": [ 20 | true, 21 | "attribute", 22 | "app", 23 | "camelCase" 24 | ], 25 | "component-selector": [ 26 | true, 27 | "element", 28 | "app", 29 | "kebab-case" 30 | ], 31 | "eofline": true, 32 | "import-blacklist": [ 33 | true, 34 | "rxjs/Rx" 35 | ], 36 | "import-spacing": true, 37 | "indent": { 38 | "options": [ 39 | "spaces" 40 | ] 41 | }, 42 | "max-classes-per-file": false, 43 | "max-line-length": [ 44 | true, 45 | 140 46 | ], 47 | "member-ordering": [ 48 | true, 49 | { 50 | "order": [ 51 | "static-field", 52 | "instance-field", 53 | "static-method", 54 | "instance-method" 55 | ] 56 | } 57 | ], 58 | "no-console": [ 59 | true, 60 | "debug", 61 | "info", 62 | "time", 63 | "timeEnd", 64 | "trace" 65 | ], 66 | "no-empty": false, 67 | "no-inferrable-types": [ 68 | true, 69 | "ignore-params" 70 | ], 71 | "no-non-null-assertion": true, 72 | "no-redundant-jsdoc": true, 73 | "no-switch-case-fall-through": true, 74 | "no-var-requires": false, 75 | "object-literal-key-quotes": [ 76 | true, 77 | "as-needed" 78 | ], 79 | "quotemark": [ 80 | true, 81 | "single" 82 | ], 83 | "semicolon": { 84 | "options": [ 85 | "always" 86 | ] 87 | }, 88 | "space-before-function-paren": { 89 | "options": { 90 | "anonymous": "never", 91 | "asyncArrow": "always", 92 | "constructor": "never", 93 | "method": "never", 94 | "named": "never" 95 | } 96 | }, 97 | "typedef": [ 98 | true, 99 | "call-signature" 100 | ], 101 | "typedef-whitespace": { 102 | "options": [ 103 | { 104 | "call-signature": "nospace", 105 | "index-signature": "nospace", 106 | "parameter": "nospace", 107 | "property-declaration": "nospace", 108 | "variable-declaration": "nospace" 109 | }, 110 | { 111 | "call-signature": "onespace", 112 | "index-signature": "onespace", 113 | "parameter": "onespace", 114 | "property-declaration": "onespace", 115 | "variable-declaration": "onespace" 116 | } 117 | ] 118 | }, 119 | "variable-name": { 120 | "options": [ 121 | "ban-keywords", 122 | "check-format", 123 | "allow-pascal-case" 124 | ] 125 | }, 126 | "whitespace": { 127 | "options": [ 128 | "check-branch", 129 | "check-decl", 130 | "check-operator", 131 | "check-separator", 132 | "check-type", 133 | "check-typecast" 134 | ] 135 | }, 136 | "no-conflicting-lifecycle": true, 137 | "no-host-metadata-property": true, 138 | "no-input-rename": true, 139 | "no-inputs-metadata-property": true, 140 | "no-output-native": true, 141 | "no-output-on-prefix": true, 142 | "no-output-rename": true, 143 | "no-outputs-metadata-property": true, 144 | "template-banana-in-box": true, 145 | "template-no-negated-async": true, 146 | "use-lifecycle-interface": true, 147 | "use-pipe-transform-interface": true 148 | }, 149 | "rulesDirectory": [ 150 | "codelyzer" 151 | ] 152 | } -------------------------------------------------------------------------------- /TrailerDownloader/Controllers/ConfigController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using TrailerDownloader.Models; 3 | using TrailerDownloader.Repositories; 4 | 5 | namespace TrailerDownloader.Controllers 6 | { 7 | [Route("api/[controller]")] 8 | [ApiController] 9 | public class ConfigController : ControllerBase 10 | { 11 | private readonly IConfigRepository _configRepository; 12 | 13 | public ConfigController(IConfigRepository configRepository) 14 | { 15 | _configRepository = configRepository; 16 | } 17 | 18 | // GET: api/ 19 | [HttpGet] 20 | public IActionResult Get() 21 | { 22 | return Ok(_configRepository.GetConfig()); 23 | } 24 | 25 | // POST api/ 26 | [HttpPost] 27 | public IActionResult Post(Config configs) 28 | { 29 | return Ok(_configRepository.SaveConfig(configs)); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /TrailerDownloader/Demo/TrailerDownloader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taylorbobaylor/TrailerDownloader/f77d78eeedb57ca07468ec7a6908983d4781d5dc/TrailerDownloader/Demo/TrailerDownloader.gif -------------------------------------------------------------------------------- /TrailerDownloader/Models/Config.cs: -------------------------------------------------------------------------------- 1 | namespace TrailerDownloader.Models 2 | { 3 | public class Config 4 | { 5 | public string MediaDirectory { get; set; } 6 | public string TrailerLanguage { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /TrailerDownloader/Models/Movie.cs: -------------------------------------------------------------------------------- 1 | namespace TrailerDownloader.Models 2 | { 3 | public class Movie 4 | { 5 | public string PosterPath { get; set; } 6 | public string TrailerURL { get; set; } 7 | public int? Id { get; set; } 8 | public string FilePath { get; set; } 9 | public string Title { get; set; } 10 | public string Year { get; set; } 11 | public bool TrailerExists { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /TrailerDownloader/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /TrailerDownloader/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using Microsoft.AspNetCore.Mvc; 3 | using Microsoft.AspNetCore.Mvc.RazorPages; 4 | using Microsoft.Extensions.Logging; 5 | 6 | namespace TrailerDownloader.Pages 7 | { 8 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 9 | public class ErrorModel : PageModel 10 | { 11 | private readonly ILogger _logger; 12 | 13 | public ErrorModel(ILogger logger) 14 | { 15 | _logger = logger; 16 | } 17 | 18 | public string RequestId { get; set; } 19 | 20 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 21 | 22 | public void OnGet() 23 | { 24 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /TrailerDownloader/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using TrailerDownloader 2 | @namespace TrailerDownloader.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /TrailerDownloader/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Hosting; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace TrailerDownloader 6 | { 7 | public class Program 8 | { 9 | public static void Main(string[] args) 10 | { 11 | CreateHostBuilder(args).Build().Run(); 12 | } 13 | 14 | public static IHostBuilder CreateHostBuilder(string[] args) => 15 | Host.CreateDefaultBuilder(args) 16 | .ConfigureLogging(logging => 17 | { 18 | logging.ClearProviders(); 19 | logging.AddConsole(); 20 | }) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /TrailerDownloader/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:51629", 7 | "sslPort": 44333 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "TrailerDownloader": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 25 | }, 26 | "Docker": { 27 | "commandName": "Docker", 28 | "launchBrowser": true, 29 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}", 30 | "publishAllPorts": true, 31 | "useSSL": true 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /TrailerDownloader/README.md: -------------------------------------------------------------------------------- 1 | # TrailerDownloader 2 | Download all the movie trailers for your Plex library 3 | -------------------------------------------------------------------------------- /TrailerDownloader/Repositories/ConfigRepository.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System.IO; 3 | using TrailerDownloader.Models; 4 | 5 | namespace TrailerDownloader.Repositories 6 | { 7 | public class ConfigRepository : IConfigRepository 8 | { 9 | private static readonly string _configPath = Path.Combine(Directory.GetCurrentDirectory(), "config.json"); 10 | 11 | public Config GetConfig() 12 | { 13 | if (File.Exists(_configPath)) 14 | { 15 | string json = File.ReadAllText(_configPath); 16 | return JsonConvert.DeserializeObject(json); 17 | } 18 | 19 | return null; 20 | } 21 | 22 | public bool SaveConfig(Config configs) 23 | { 24 | if (Directory.Exists(configs.MediaDirectory) == false) 25 | { 26 | return false; 27 | } 28 | 29 | File.WriteAllText(_configPath, JsonConvert.SerializeObject(configs)); 30 | return true; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /TrailerDownloader/Repositories/IConfigRepository.cs: -------------------------------------------------------------------------------- 1 | using TrailerDownloader.Models; 2 | 3 | namespace TrailerDownloader.Repositories 4 | { 5 | public interface IConfigRepository 6 | { 7 | Config GetConfig(); 8 | bool SaveConfig(Config configs); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /TrailerDownloader/Repositories/ITrailerRepository.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Threading.Tasks; 3 | using TrailerDownloader.Models; 4 | 5 | namespace TrailerDownloader.Repositories 6 | { 7 | public interface ITrailerRepository 8 | { 9 | Task GetAllMoviesInfo(); 10 | Task DownloadAllTrailers(IEnumerable movieList); 11 | bool DeleteAllTrailers(IEnumerable movieList); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /TrailerDownloader/SignalRHubs/MovieHub.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.SignalR; 2 | using Microsoft.Extensions.Logging; 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Net.Http; 10 | using System.Text.RegularExpressions; 11 | using System.Threading.Tasks; 12 | using TrailerDownloader.Models; 13 | using TrailerDownloader.Repositories; 14 | using YoutubeExplode; 15 | using YoutubeExplode.Converter; 16 | 17 | namespace TrailerDownloader.SignalRHubs; 18 | 19 | public class MovieHub : Hub, ITrailerRepository 20 | { 21 | private readonly IHttpClientFactory _httpClientFactory; 22 | private readonly ILogger _logger; 23 | private static IHubContext _hubContext; 24 | private static readonly Dictionary _movieDictionary = new(); 25 | 26 | private static readonly string _apiKey = "e438e2812f17faa299396505f2b375bb"; 27 | private static readonly string _configPath = Path.Combine(Directory.GetCurrentDirectory(), "config.json"); 28 | private static readonly List _excludedFileExtensions = new List() { ".srt", ".sub", ".sbv", ".ssa", ".SRT2UTF-8", ".STL", ".png", ".jpg", ".jpeg", ".png", ".gif", ".svg", ".tif", ".tif", ".txt", ".nfo" }; 29 | private static string _mainMovieDirectory; 30 | private static string _trailerLanguage; 31 | private static readonly List _movieDirectories = new List(); 32 | private object _lock = new(); 33 | 34 | public MovieHub(IHttpClientFactory httpClientFactory, ILogger logger, IHubContext hubContext) 35 | { 36 | _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); 37 | _logger = logger ?? throw new ArgumentNullException(nameof(logger)); 38 | _hubContext = hubContext ?? throw new ArgumentNullException(nameof(hubContext)); 39 | 40 | if (File.Exists(_configPath)) 41 | { 42 | try 43 | { 44 | string jsonConfig = File.ReadAllText(_configPath); 45 | Config config = JsonConvert.DeserializeObject(jsonConfig); 46 | _mainMovieDirectory = config.MediaDirectory; 47 | _trailerLanguage = config.TrailerLanguage; 48 | } 49 | catch (Exception ex) 50 | { 51 | _logger.LogError(ex, "Error reading or deserializing config file at {ConfigPath}", _configPath); 52 | } 53 | } 54 | } 55 | 56 | public async Task GetAllMoviesInfo() 57 | { 58 | GetMovieDirectories(_mainMovieDirectory); 59 | List> taskList = new List>(); 60 | 61 | foreach (string movieDirectory in _movieDirectories) 62 | { 63 | foreach (string movieDirectory1 in Directory.GetDirectories(movieDirectory)) 64 | { 65 | Movie movie = GetMovieFromDirectory(movieDirectory1); 66 | if (movie == null) 67 | { 68 | _logger.LogInformation($"No movie found in directory: '{movieDirectory1}'"); 69 | continue; 70 | } 71 | 72 | if (_movieDictionary.TryGetValue(movie.Title, out Movie dictionaryMovie)) 73 | { 74 | dictionaryMovie.TrailerExists = movie.TrailerExists; 75 | await _hubContext.Clients.All.SendAsync("getAllMoviesInfo", dictionaryMovie).ConfigureAwait(false); 76 | } 77 | else 78 | { 79 | taskList.Add(GetMovieInfoAsync(movie)); 80 | } 81 | } 82 | } 83 | 84 | if (taskList.Count > 0) 85 | { 86 | _ = await Task.WhenAll(taskList).ConfigureAwait(false); 87 | } 88 | 89 | _movieDictionary.ToList().ForEach(mov => 90 | { 91 | if (Directory.Exists(mov.Value.FilePath) == false) 92 | { 93 | _ = _movieDictionary.Remove(mov.Value.FilePath); 94 | } 95 | }); 96 | 97 | await _hubContext.Clients.All.SendAsync("completedAllMoviesInfo", _movieDictionary.Count).ConfigureAwait(false); 98 | } 99 | 100 | private void GetMovieDirectories(string directoryPath) 101 | { 102 | try 103 | { 104 | _movieDirectories.Clear(); 105 | 106 | // Enumerate all subdirectories 107 | var subDirectories = Directory.EnumerateDirectories(directoryPath, "*", SearchOption.AllDirectories); 108 | 109 | // Add the movie directories to the collection 110 | var hasSubdirectories = false; 111 | foreach (var subDirectory in subDirectories) 112 | { 113 | if (Directory.GetDirectories(subDirectory).Length <= 0) continue; 114 | if (!subDirectory.Contains("Subs")) continue; 115 | if (!subDirectory.Contains("Subtitles")) continue; 116 | _movieDirectories.Add(subDirectory); 117 | hasSubdirectories = true; 118 | } 119 | 120 | // If no subdirectories were added, add the main directoryPath 121 | if (!hasSubdirectories) 122 | { 123 | _movieDirectories.Add(directoryPath); 124 | } 125 | } 126 | catch (Exception ex) 127 | { 128 | _logger.LogError(ex, "Error in GetMovieDirectories() for directory path {DirectoryPath}", directoryPath); 129 | } 130 | } 131 | 132 | 133 | private Movie GetMovieFromDirectory(string movieDirectory) 134 | { 135 | if (Directory.GetFiles(movieDirectory).Length == 0) 136 | { 137 | return null; 138 | } 139 | 140 | bool trailerExists = Directory.GetFiles(movieDirectory).Where(name => name.Contains("-trailer")).Count() > 0; 141 | string filePath = Directory.GetFiles(movieDirectory).FirstOrDefault(file => !_excludedFileExtensions.Any(x => file.EndsWith(x)) && !file.Contains("-trailer")); 142 | string title = Regex.Replace(Path.GetFileNameWithoutExtension(filePath), @"\(.*", string.Empty).Trim().Replace("-trailer", string.Empty); 143 | string year = Regex.Match(Path.GetFileNameWithoutExtension(filePath), @"\(\d*").Captures.FirstOrDefault()?.Value.Replace("(", string.Empty); 144 | 145 | return new Movie 146 | { 147 | TrailerExists = trailerExists, 148 | FilePath = Path.GetDirectoryName(filePath), 149 | Title = title, 150 | Year = year 151 | }; 152 | } 153 | 154 | public async Task DownloadAllTrailers(IEnumerable movieList) 155 | { 156 | foreach (Movie movie in movieList.OrderBy(movie => movie.Title)) 157 | { 158 | if (movie.TrailerExists == false && string.IsNullOrEmpty(movie.TrailerURL) == false) 159 | { 160 | if (DownloadTrailerAsync(movie).Result) 161 | { 162 | movie.TrailerExists = true; 163 | await _hubContext.Clients.All.SendAsync("downloadAllTrailers", movie); 164 | } 165 | } 166 | } 167 | 168 | await _hubContext.Clients.All.SendAsync("doneDownloadingAllTrailersListener", true); 169 | } 170 | 171 | public bool DeleteAllTrailers(IEnumerable movieList) 172 | { 173 | ParallelLoopResult result = Parallel.ForEach(movieList, async movie => 174 | { 175 | if (movie.TrailerExists) 176 | { 177 | string filePath = Directory.GetFiles(movie.FilePath).Where(name => name.Contains("-trailer")).FirstOrDefault(); 178 | File.Delete(filePath); 179 | movie.TrailerExists = false; 180 | _movieDictionary.FirstOrDefault(mov => mov.Value.FilePath == movie.FilePath).Value.TrailerExists = false; 181 | await _hubContext.Clients.All.SendAsync("deleteAllTrailers", movie); 182 | } 183 | }); 184 | 185 | return result.IsCompleted; 186 | } 187 | 188 | private async Task DownloadTrailerAsync(Movie movie) 189 | { 190 | try 191 | { 192 | var youtube = new YoutubeClient(); 193 | var videoUrl = movie.TrailerURL; 194 | var outputFilePath = Path.Combine(movie.FilePath, $"{movie.Title} ({movie.Year})-trailer.mp4"); 195 | 196 | await youtube.Videos.DownloadAsync(videoUrl, outputFilePath); 197 | 198 | _logger.LogInformation("Successfully downloaded trailer for {MovieTitle}", movie.Title); 199 | return true; 200 | } 201 | catch (Exception ex) 202 | { 203 | _logger.LogError(ex, "Error downloading trailer for {MovieTitle}", movie.Title); 204 | await _hubContext.Clients.All.SendAsync("downloadAllTrailers", movie); 205 | return false; 206 | } 207 | } 208 | 209 | private async Task GetMovieInfoAsync(Movie movie) 210 | { 211 | try 212 | { 213 | HttpClient httpClient = _httpClientFactory.CreateClient(); 214 | 215 | string uri = $"https://api.themoviedb.org/3/search/movie?language=en-US&query={movie.Title}&year={movie.Year}&api_key={_apiKey}"; 216 | HttpResponseMessage response = await httpClient.GetAsync(new Uri(uri)); 217 | 218 | if (response.IsSuccessStatusCode) 219 | { 220 | JToken results = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()).GetValue("results"); 221 | JToken singleResult = results.FirstOrDefault(j => j.Value("title") == movie.Title); 222 | 223 | if (singleResult != null) 224 | { 225 | movie.PosterPath = $"https://image.tmdb.org/t/p/w500/{singleResult.Value("poster_path")}"; 226 | movie.Id = singleResult.Value("id"); 227 | } 228 | else if (results != null) 229 | { 230 | movie.PosterPath = $"https://image.tmdb.org/t/p/w500/{results.First?.Value("poster_path")}"; 231 | movie.Id = results.First?.Value("id"); 232 | } 233 | 234 | movie.TrailerURL = await GetTrailerURL(movie.Id); 235 | await _hubContext.Clients.All.SendAsync("getAllMoviesInfo", movie); 236 | 237 | lock (_lock) 238 | { 239 | _movieDictionary.TryAdd(movie.FilePath, movie); 240 | } 241 | 242 | return movie; 243 | } 244 | 245 | return null; 246 | } 247 | catch (Exception ex) 248 | { 249 | _logger.LogError(ex, "Error getting movie info for {MovieTitle}", movie.Title); 250 | return null; 251 | } 252 | } 253 | 254 | private async Task GetTrailerURL(int? id) 255 | { 256 | if (id != null) 257 | { 258 | try 259 | { 260 | HttpClient httpClient = _httpClientFactory.CreateClient(); 261 | string uri = $"https://api.themoviedb.org/3/movie/{id}/videos?api_key={_apiKey}&language={_trailerLanguage}"; 262 | 263 | HttpResponseMessage response = await httpClient.GetAsync(new Uri(uri)); 264 | if (response.IsSuccessStatusCode) 265 | { 266 | JToken results = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync()).GetValue("results"); 267 | if (results.Count() != 0) 268 | { 269 | foreach (JToken result in results) 270 | { 271 | if (result.Value("site") == "YouTube") 272 | { 273 | if (result.Value("type") == "Trailer") 274 | { 275 | return result.Value("key"); 276 | } 277 | } 278 | } 279 | } 280 | } 281 | } 282 | catch (Exception ex) 283 | { 284 | _logger.LogError(ex, "Error getting trailer URL for movie ID {MovieId}", id); 285 | } 286 | } 287 | 288 | return string.Empty; 289 | } 290 | } 291 | -------------------------------------------------------------------------------- /TrailerDownloader/Startup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Builder; 2 | using Microsoft.AspNetCore.Hosting; 3 | using Microsoft.AspNetCore.SpaServices.AngularCli; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using Microsoft.Extensions.Hosting; 7 | using System; 8 | using TrailerDownloader.Repositories; 9 | using TrailerDownloader.SignalRHubs; 10 | 11 | namespace TrailerDownloader 12 | { 13 | public class Startup 14 | { 15 | public Startup(IConfiguration configuration) 16 | { 17 | Configuration = configuration; 18 | } 19 | 20 | public IConfiguration Configuration { get; } 21 | 22 | // This method gets called by the runtime. Use this method to add services to the container. 23 | public void ConfigureServices(IServiceCollection services) 24 | { 25 | services.AddCors(options => 26 | { 27 | options.AddPolicy("CorsPolicy", builder => 28 | builder.SetIsOriginAllowed(origin => new Uri(origin).Host == "localhost") 29 | .AllowAnyMethod() 30 | .AllowAnyHeader() 31 | .AllowCredentials()); 32 | }); 33 | 34 | services.AddControllersWithViews(); 35 | 36 | services.AddHttpClient(); 37 | 38 | // In production, the Angular files will be served from this directory 39 | services.AddSpaStaticFiles(configuration => 40 | { 41 | configuration.RootPath = "ClientApp/dist"; 42 | }); 43 | 44 | services.AddScoped(); 45 | services.AddScoped(); 46 | 47 | services.AddSignalR(x => 48 | { 49 | x.MaximumReceiveMessageSize = 102400000; 50 | }); 51 | } 52 | 53 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 54 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 55 | { 56 | if (env.IsDevelopment()) 57 | { 58 | app.UseDeveloperExceptionPage(); 59 | } 60 | else 61 | { 62 | app.UseExceptionHandler("/Error"); 63 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 64 | app.UseHsts(); 65 | } 66 | 67 | app.UseHttpsRedirection(); 68 | app.UseStaticFiles(); 69 | if (!env.IsDevelopment()) 70 | { 71 | app.UseSpaStaticFiles(); 72 | } 73 | 74 | app.UseRouting(); 75 | 76 | app.UseCors("CorsPolicy"); 77 | 78 | app.UseEndpoints(endpoints => 79 | { 80 | endpoints.MapControllerRoute( 81 | name: "default", 82 | pattern: "{controller}/{action=Index}/{id?}"); 83 | }); 84 | 85 | app.UseSpa(spa => 86 | { 87 | // To learn more about options for serving an Angular SPA from ASP.NET Core, 88 | // see https://go.microsoft.com/fwlink/?linkid=864501 89 | 90 | spa.Options.SourcePath = "ClientApp"; 91 | 92 | if (env.IsDevelopment()) 93 | { 94 | spa.UseAngularCliServer(npmScript: "start"); 95 | } 96 | }); 97 | 98 | app.UseEndpoints(endpoints => 99 | { 100 | endpoints.MapControllers(); 101 | endpoints.MapHub("/moviehub"); 102 | }); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /TrailerDownloader/TrailerDownloader.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | true 6 | Latest 7 | false 8 | ClientApp\ 9 | $(DefaultItemExcludes);$(SpaRoot)node_modules\** 10 | 11 | 12 | false 13 | eaa1a05b-73fc-4a7f-a623-a9c4f79abf4c 14 | Linux 15 | enable 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | .dockerignore 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | %(DistFiles.Identity) 65 | PreserveNewest 66 | true 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /TrailerDownloader/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information", 7 | "System.Net.Http.HttpClient": "Warning" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /TrailerDownloader/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information", 7 | "System.Net.Http.HttpClient": "Warning" 8 | } 9 | }, 10 | "AllowedHosts": "*" 11 | } 12 | -------------------------------------------------------------------------------- /TrailerDownloader/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taylorbobaylor/TrailerDownloader/f77d78eeedb57ca07468ec7a6908983d4781d5dc/TrailerDownloader/wwwroot/favicon.ico --------------------------------------------------------------------------------