From 1186ebf7553e8f8a2d4ba0cfdc00cff2bbab80d9 Mon Sep 17 00:00:00 2001 From: Jamie Brunton Date: Mon, 13 Feb 2023 21:14:16 +0000 Subject: [PATCH] Add model mapping --- .vscode/launch.json | 39 +++ .vscode/tasks.json | 110 +++++++ src/Convertarr.Core/Convertarr.Core.csproj | 1 + .../Converters/NullStringConverter.cs | 12 + src/Convertarr.Core/MediaInfoService.cs | 16 +- ...0230210230745_MyFirstMigration.Designer.cs | 39 --- .../20230210230745_MyFirstMigration.cs | 34 --- .../20230211164210_MediaAnalysis.Designer.cs | 66 ----- .../20230211164210_MediaAnalysis.cs | 112 -------- .../20230211172658_Codec.Designer.cs | 70 ----- .../Migrations/20230211172658_Codec.cs | 29 -- ...20230211173316_CodecConstraint.Designer.cs | 69 ----- .../20230211173316_CodecConstraint.cs | 59 ---- .../20230211181606_FileHash.Designer.cs | 76 ----- .../Migrations/20230211181606_FileHash.cs | 41 --- .../20230211182032_Attributes.Designer.cs | 79 ----- .../Migrations/20230211182032_Attributes.cs | 39 --- ...211182140_AttributesWithLength.Designer.cs | 78 ----- .../20230211182140_AttributesWithLength.cs | 34 --- .../20230213211154_Initial.Designer.cs | 269 ++++++++++++++++++ .../Migrations/20230213211154_Initial.cs | 177 ++++++++++++ .../ConvertarrContextModelSnapshot.cs | 195 ++++++++++++- src/Convertarr.Data/Models/AudioStream.cs | 45 +++ src/Convertarr.Data/Models/MediaInfo.cs | 10 +- src/Convertarr.Data/Models/MediaStream.cs | 22 ++ src/Convertarr.Data/Models/MediaStreamType.cs | 21 ++ src/Convertarr.Data/Models/SubtitleStream.cs | 29 ++ src/Convertarr.Data/Models/VideoStream.cs | 53 ++++ src/Convertarr.Web/Convertarr.Web.csproj | 4 +- 29 files changed, 997 insertions(+), 831 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 src/Convertarr.Core/Converters/NullStringConverter.cs delete mode 100644 src/Convertarr.Data/Migrations/20230210230745_MyFirstMigration.Designer.cs delete mode 100644 src/Convertarr.Data/Migrations/20230210230745_MyFirstMigration.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211164210_MediaAnalysis.Designer.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211164210_MediaAnalysis.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211172658_Codec.Designer.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211172658_Codec.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211173316_CodecConstraint.Designer.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211173316_CodecConstraint.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211181606_FileHash.Designer.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211181606_FileHash.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211182032_Attributes.Designer.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211182032_Attributes.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211182140_AttributesWithLength.Designer.cs delete mode 100644 src/Convertarr.Data/Migrations/20230211182140_AttributesWithLength.cs create mode 100644 src/Convertarr.Data/Migrations/20230213211154_Initial.Designer.cs create mode 100644 src/Convertarr.Data/Migrations/20230213211154_Initial.cs create mode 100644 src/Convertarr.Data/Models/AudioStream.cs create mode 100644 src/Convertarr.Data/Models/MediaStream.cs create mode 100644 src/Convertarr.Data/Models/MediaStreamType.cs create mode 100644 src/Convertarr.Data/Models/SubtitleStream.cs create mode 100644 src/Convertarr.Data/Models/VideoStream.cs diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..113ad39 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,39 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/src/Convertarr.Web/bin/Debug/net7.0/Convertarr.Web.dll", + "args": [], + "cwd": "${workspaceFolder}/src/Convertarr.Web", + "stopAtEntry": false, + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + }, + { + "name": "Docker .NET Core Launch", + "type": "docker", + "request": "launch", + "preLaunchTask": "docker-run: debug", + "netCore": { + "appProject": "${workspaceFolder}/src/Convertarr.Web/Convertarr.Web.csproj" + } + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..14fded3 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,110 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/src/Convertarr.Web/Convertarr.Web.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/src/Convertarr.Web/Convertarr.Web.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/src/Convertarr.Web/Convertarr.Web.csproj" + ], + "problemMatcher": "$msCompile" + }, + { + "type": "docker-build", + "label": "docker-build: debug", + "dependsOn": [ + "build" + ], + "dockerBuild": { + "tag": "convertarr:dev", + "target": "base", + "dockerfile": "${workspaceFolder}/src/Convertarr.Web/Dockerfile", + "context": "${workspaceFolder}", + "pull": true + }, + "netCore": { + "appProject": "${workspaceFolder}/src/Convertarr.Web/Convertarr.Web.csproj" + } + }, + { + "type": "docker-build", + "label": "docker-build: release", + "dependsOn": [ + "build" + ], + "dockerBuild": { + "tag": "convertarr:latest", + "dockerfile": "${workspaceFolder}/src/Convertarr.Web/Dockerfile", + "context": "${workspaceFolder}", + "pull": true + }, + "netCore": { + "appProject": "${workspaceFolder}/src/Convertarr.Web/Convertarr.Web.csproj" + } + }, + { + "type": "docker-run", + "label": "docker-run: debug", + "dependsOn": [ + "docker-build: debug" + ], + "dockerRun": { + "volumes": [ + { + "containerPath": "/media", + "localPath": "/Users/jamiebrunton/Movies", + "permissions": "rw" + }, + { + "containerPath": "/config", + "localPath": "/Users/jamiebrunton/Documents/Projects/ConvertarrConfig", + "permissions": "rw" + } + ] + }, + "netCore": { + "appProject": "${workspaceFolder}/src/Convertarr.Web/Convertarr.Web.csproj", + "enableDebugging": true + } + }, + { + "type": "docker-run", + "label": "docker-run: release", + "dependsOn": [ + "docker-build: release" + ], + "dockerRun": {}, + "netCore": { + "appProject": "${workspaceFolder}/src/Convertarr.Web/Convertarr.Web.csproj" + } + } + ] +} \ No newline at end of file diff --git a/src/Convertarr.Core/Convertarr.Core.csproj b/src/Convertarr.Core/Convertarr.Core.csproj index 6a2b686..721b66c 100644 --- a/src/Convertarr.Core/Convertarr.Core.csproj +++ b/src/Convertarr.Core/Convertarr.Core.csproj @@ -8,6 +8,7 @@ + diff --git a/src/Convertarr.Core/Converters/NullStringConverter.cs b/src/Convertarr.Core/Converters/NullStringConverter.cs new file mode 100644 index 0000000..df13fed --- /dev/null +++ b/src/Convertarr.Core/Converters/NullStringConverter.cs @@ -0,0 +1,12 @@ +using AutoMapper; + +namespace Convertarr.Core.Converters +{ + public class NullStringConverter : ITypeConverter + { + public string Convert(string source, string destination, ResolutionContext context) + { + return source ?? string.Empty; + } + } +} \ No newline at end of file diff --git a/src/Convertarr.Core/MediaInfoService.cs b/src/Convertarr.Core/MediaInfoService.cs index 7ea9ecb..3f79574 100644 --- a/src/Convertarr.Core/MediaInfoService.cs +++ b/src/Convertarr.Core/MediaInfoService.cs @@ -5,6 +5,8 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using AutoMapper; +using Convertarr.Core.Converters; using Convertarr.Data; using Convertarr.Data.Models; using Hangfire; @@ -40,12 +42,24 @@ namespace Convertarr.Core { return; } + var config = new MapperConfiguration(cfg => + { + cfg.CreateMap().ConvertUsing(); + cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); + } + ); + var mapper = new Mapper(config); Debug.WriteLine($"Starting analysis for {dbFile.FilePath}"); var fileInfo = await FFmpeg.GetMediaInfo(dbFile.FilePath); dbFile.MediaInfo = new Convertarr.Data.Models.MediaInfo { - Codec = fileInfo.VideoStreams.First().Codec + Duration = fileInfo.Duration, + VideoStreams = fileInfo.VideoStreams.Select(x => mapper.Map(x)), + AudioStreams = fileInfo.AudioStreams.Select(x => mapper.Map(x)), + SubtitleStreams = fileInfo.SubtitleStreams.Select(x => mapper.Map(x)) }; this._context.Update(dbFile); diff --git a/src/Convertarr.Data/Migrations/20230210230745_MyFirstMigration.Designer.cs b/src/Convertarr.Data/Migrations/20230210230745_MyFirstMigration.Designer.cs deleted file mode 100644 index 0c9e056..0000000 --- a/src/Convertarr.Data/Migrations/20230210230745_MyFirstMigration.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -// -using Convertarr.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - [DbContext(typeof(ConvertarrContext))] - [Migration("20230210230745_MyFirstMigration")] - partial class MyFirstMigration - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Convertarr.Data.Models.MediaFile", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FilePath") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("Id"); - - b.ToTable("Files"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230210230745_MyFirstMigration.cs b/src/Convertarr.Data/Migrations/20230210230745_MyFirstMigration.cs deleted file mode 100644 index 7362798..0000000 --- a/src/Convertarr.Data/Migrations/20230210230745_MyFirstMigration.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - /// - public partial class MyFirstMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Files", - columns: table => new - { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - FilePath = table.Column(type: "TEXT", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Files", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Files"); - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211164210_MediaAnalysis.Designer.cs b/src/Convertarr.Data/Migrations/20230211164210_MediaAnalysis.Designer.cs deleted file mode 100644 index 45c7ac4..0000000 --- a/src/Convertarr.Data/Migrations/20230211164210_MediaAnalysis.Designer.cs +++ /dev/null @@ -1,66 +0,0 @@ -// -using Convertarr.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - [DbContext(typeof(ConvertarrContext))] - [Migration("20230211164210_MediaAnalysis")] - partial class MediaAnalysis - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.Property("MediaFileId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FilePath") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("MediaInfoId") - .HasColumnType("INTEGER"); - - b.HasKey("MediaFileId"); - - b.HasIndex("MediaInfoId"); - - b.ToTable("Files"); - }); - - modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => - { - b.Property("MediaInfoId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.HasKey("MediaInfoId"); - - b.ToTable("MediaInfo"); - }); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.HasOne("Convertarr.Data.Models.MediaInfo", "MediaInfo") - .WithMany() - .HasForeignKey("MediaInfoId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("MediaInfo"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211164210_MediaAnalysis.cs b/src/Convertarr.Data/Migrations/20230211164210_MediaAnalysis.cs deleted file mode 100644 index 9c12556..0000000 --- a/src/Convertarr.Data/Migrations/20230211164210_MediaAnalysis.cs +++ /dev/null @@ -1,112 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - /// - public partial class MediaAnalysis : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_Files", - table: "Files"); - - migrationBuilder.RenameColumn( - name: "Id", - table: "Files", - newName: "MediaInfoId"); - - migrationBuilder.AlterColumn( - name: "MediaInfoId", - table: "Files", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER") - .OldAnnotation("Sqlite:Autoincrement", true); - - migrationBuilder.AddColumn( - name: "MediaFileId", - table: "Files", - type: "INTEGER", - nullable: false, - defaultValue: 0) - .Annotation("Sqlite:Autoincrement", true); - - migrationBuilder.AddPrimaryKey( - name: "PK_Files", - table: "Files", - column: "MediaFileId"); - - migrationBuilder.CreateTable( - name: "MediaInfo", - columns: table => new - { - MediaInfoId = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true) - }, - constraints: table => - { - table.PrimaryKey("PK_MediaInfo", x => x.MediaInfoId); - }); - - migrationBuilder.CreateIndex( - name: "IX_Files_MediaInfoId", - table: "Files", - column: "MediaInfoId"); - - migrationBuilder.AddForeignKey( - name: "FK_Files_MediaInfo_MediaInfoId", - table: "Files", - column: "MediaInfoId", - principalTable: "MediaInfo", - principalColumn: "MediaInfoId", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Files_MediaInfo_MediaInfoId", - table: "Files"); - - migrationBuilder.DropTable( - name: "MediaInfo"); - - migrationBuilder.DropPrimaryKey( - name: "PK_Files", - table: "Files"); - - migrationBuilder.DropIndex( - name: "IX_Files_MediaInfoId", - table: "Files"); - - migrationBuilder.DropColumn( - name: "MediaFileId", - table: "Files"); - - migrationBuilder.RenameColumn( - name: "MediaInfoId", - table: "Files", - newName: "Id"); - - migrationBuilder.AlterColumn( - name: "Id", - table: "Files", - type: "INTEGER", - nullable: false, - oldClrType: typeof(int), - oldType: "INTEGER") - .Annotation("Sqlite:Autoincrement", true); - - migrationBuilder.AddPrimaryKey( - name: "PK_Files", - table: "Files", - column: "Id"); - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211172658_Codec.Designer.cs b/src/Convertarr.Data/Migrations/20230211172658_Codec.Designer.cs deleted file mode 100644 index 3813e20..0000000 --- a/src/Convertarr.Data/Migrations/20230211172658_Codec.Designer.cs +++ /dev/null @@ -1,70 +0,0 @@ -// -using Convertarr.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - [DbContext(typeof(ConvertarrContext))] - [Migration("20230211172658_Codec")] - partial class Codec - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.Property("MediaFileId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FilePath") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("MediaInfoId") - .HasColumnType("INTEGER"); - - b.HasKey("MediaFileId"); - - b.HasIndex("MediaInfoId"); - - b.ToTable("Files"); - }); - - modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => - { - b.Property("MediaInfoId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Codec") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("MediaInfoId"); - - b.ToTable("MediaInfo"); - }); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.HasOne("Convertarr.Data.Models.MediaInfo", "MediaInfo") - .WithMany() - .HasForeignKey("MediaInfoId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("MediaInfo"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211172658_Codec.cs b/src/Convertarr.Data/Migrations/20230211172658_Codec.cs deleted file mode 100644 index 9966a46..0000000 --- a/src/Convertarr.Data/Migrations/20230211172658_Codec.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - /// - public partial class Codec : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Codec", - table: "MediaInfo", - type: "TEXT", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Codec", - table: "MediaInfo"); - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211173316_CodecConstraint.Designer.cs b/src/Convertarr.Data/Migrations/20230211173316_CodecConstraint.Designer.cs deleted file mode 100644 index 3925c38..0000000 --- a/src/Convertarr.Data/Migrations/20230211173316_CodecConstraint.Designer.cs +++ /dev/null @@ -1,69 +0,0 @@ -// -using System; -using Convertarr.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - [DbContext(typeof(ConvertarrContext))] - [Migration("20230211173316_CodecConstraint")] - partial class CodecConstraint - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.Property("MediaFileId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FilePath") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("MediaInfoId") - .HasColumnType("INTEGER"); - - b.HasKey("MediaFileId"); - - b.HasIndex("MediaInfoId"); - - b.ToTable("Files"); - }); - - modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => - { - b.Property("MediaInfoId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Codec") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("MediaInfoId"); - - b.ToTable("MediaInfo"); - }); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.HasOne("Convertarr.Data.Models.MediaInfo", "MediaInfo") - .WithMany() - .HasForeignKey("MediaInfoId"); - - b.Navigation("MediaInfo"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211173316_CodecConstraint.cs b/src/Convertarr.Data/Migrations/20230211173316_CodecConstraint.cs deleted file mode 100644 index e8b14ec..0000000 --- a/src/Convertarr.Data/Migrations/20230211173316_CodecConstraint.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - /// - public partial class CodecConstraint : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Files_MediaInfo_MediaInfoId", - table: "Files"); - - migrationBuilder.AlterColumn( - name: "MediaInfoId", - table: "Files", - type: "INTEGER", - nullable: true, - oldClrType: typeof(int), - oldType: "INTEGER"); - - migrationBuilder.AddForeignKey( - name: "FK_Files_MediaInfo_MediaInfoId", - table: "Files", - column: "MediaInfoId", - principalTable: "MediaInfo", - principalColumn: "MediaInfoId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Files_MediaInfo_MediaInfoId", - table: "Files"); - - migrationBuilder.AlterColumn( - name: "MediaInfoId", - table: "Files", - type: "INTEGER", - nullable: false, - defaultValue: 0, - oldClrType: typeof(int), - oldType: "INTEGER", - oldNullable: true); - - migrationBuilder.AddForeignKey( - name: "FK_Files_MediaInfo_MediaInfoId", - table: "Files", - column: "MediaInfoId", - principalTable: "MediaInfo", - principalColumn: "MediaInfoId", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211181606_FileHash.Designer.cs b/src/Convertarr.Data/Migrations/20230211181606_FileHash.Designer.cs deleted file mode 100644 index 85e68b8..0000000 --- a/src/Convertarr.Data/Migrations/20230211181606_FileHash.Designer.cs +++ /dev/null @@ -1,76 +0,0 @@ -// -using System; -using Convertarr.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - [DbContext(typeof(ConvertarrContext))] - [Migration("20230211181606_FileHash")] - partial class FileHash - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.Property("MediaFileId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FileHash") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("FilePath") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LastScanned") - .HasColumnType("TEXT"); - - b.Property("MediaInfoId") - .HasColumnType("INTEGER"); - - b.HasKey("MediaFileId"); - - b.HasIndex("MediaInfoId"); - - b.ToTable("Files"); - }); - - modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => - { - b.Property("MediaInfoId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Codec") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("MediaInfoId"); - - b.ToTable("MediaInfo"); - }); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.HasOne("Convertarr.Data.Models.MediaInfo", "MediaInfo") - .WithMany() - .HasForeignKey("MediaInfoId"); - - b.Navigation("MediaInfo"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211181606_FileHash.cs b/src/Convertarr.Data/Migrations/20230211181606_FileHash.cs deleted file mode 100644 index 294661c..0000000 --- a/src/Convertarr.Data/Migrations/20230211181606_FileHash.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - /// - public partial class FileHash : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "FileHash", - table: "Files", - type: "TEXT", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "LastScanned", - table: "Files", - type: "TEXT", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "FileHash", - table: "Files"); - - migrationBuilder.DropColumn( - name: "LastScanned", - table: "Files"); - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211182032_Attributes.Designer.cs b/src/Convertarr.Data/Migrations/20230211182032_Attributes.Designer.cs deleted file mode 100644 index bffb99c..0000000 --- a/src/Convertarr.Data/Migrations/20230211182032_Attributes.Designer.cs +++ /dev/null @@ -1,79 +0,0 @@ -// -using System; -using Convertarr.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - [DbContext(typeof(ConvertarrContext))] - [Migration("20230211182032_Attributes")] - partial class Attributes - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.Property("MediaFileId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FilePath") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("FileSize") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("LastScanned") - .HasColumnType("TEXT"); - - b.Property("LastWrite") - .HasColumnType("TEXT"); - - b.Property("MediaInfoId") - .HasColumnType("INTEGER"); - - b.HasKey("MediaFileId"); - - b.HasIndex("MediaInfoId"); - - b.ToTable("Files"); - }); - - modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => - { - b.Property("MediaInfoId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Codec") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("MediaInfoId"); - - b.ToTable("MediaInfo"); - }); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.HasOne("Convertarr.Data.Models.MediaInfo", "MediaInfo") - .WithMany() - .HasForeignKey("MediaInfoId"); - - b.Navigation("MediaInfo"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211182032_Attributes.cs b/src/Convertarr.Data/Migrations/20230211182032_Attributes.cs deleted file mode 100644 index 5a1e66b..0000000 --- a/src/Convertarr.Data/Migrations/20230211182032_Attributes.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - /// - public partial class Attributes : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "FileHash", - table: "Files", - newName: "LastWrite"); - - migrationBuilder.AddColumn( - name: "FileSize", - table: "Files", - type: "TEXT", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "FileSize", - table: "Files"); - - migrationBuilder.RenameColumn( - name: "LastWrite", - table: "Files", - newName: "FileHash"); - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211182140_AttributesWithLength.Designer.cs b/src/Convertarr.Data/Migrations/20230211182140_AttributesWithLength.Designer.cs deleted file mode 100644 index 3613664..0000000 --- a/src/Convertarr.Data/Migrations/20230211182140_AttributesWithLength.Designer.cs +++ /dev/null @@ -1,78 +0,0 @@ -// -using System; -using Convertarr.Data; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - [DbContext(typeof(ConvertarrContext))] - [Migration("20230211182140_AttributesWithLength")] - partial class AttributesWithLength - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.Property("MediaFileId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("FilePath") - .IsRequired() - .HasColumnType("TEXT"); - - b.Property("FileSize") - .HasColumnType("INTEGER"); - - b.Property("LastScanned") - .HasColumnType("TEXT"); - - b.Property("LastWrite") - .HasColumnType("TEXT"); - - b.Property("MediaInfoId") - .HasColumnType("INTEGER"); - - b.HasKey("MediaFileId"); - - b.HasIndex("MediaInfoId"); - - b.ToTable("Files"); - }); - - modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => - { - b.Property("MediaInfoId") - .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); - - b.Property("Codec") - .IsRequired() - .HasColumnType("TEXT"); - - b.HasKey("MediaInfoId"); - - b.ToTable("MediaInfo"); - }); - - modelBuilder.Entity("Convertarr.Data.MediaFile", b => - { - b.HasOne("Convertarr.Data.Models.MediaInfo", "MediaInfo") - .WithMany() - .HasForeignKey("MediaInfoId"); - - b.Navigation("MediaInfo"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230211182140_AttributesWithLength.cs b/src/Convertarr.Data/Migrations/20230211182140_AttributesWithLength.cs deleted file mode 100644 index 293ec0f..0000000 --- a/src/Convertarr.Data/Migrations/20230211182140_AttributesWithLength.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Convertarr.Data.Migrations -{ - /// - public partial class AttributesWithLength : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "FileSize", - table: "Files", - type: "INTEGER", - nullable: false, - oldClrType: typeof(string), - oldType: "TEXT"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "FileSize", - table: "Files", - type: "TEXT", - nullable: false, - oldClrType: typeof(long), - oldType: "INTEGER"); - } - } -} diff --git a/src/Convertarr.Data/Migrations/20230213211154_Initial.Designer.cs b/src/Convertarr.Data/Migrations/20230213211154_Initial.Designer.cs new file mode 100644 index 0000000..533a68f --- /dev/null +++ b/src/Convertarr.Data/Migrations/20230213211154_Initial.Designer.cs @@ -0,0 +1,269 @@ +// +using System; +using Convertarr.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Convertarr.Data.Migrations +{ + [DbContext(typeof(ConvertarrContext))] + [Migration("20230213211154_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "7.0.2"); + + modelBuilder.Entity("Convertarr.Data.MediaFile", b => + { + b.Property("MediaFileId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("FilePath") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("FileSize") + .HasColumnType("INTEGER"); + + b.Property("LastScanned") + .HasColumnType("TEXT"); + + b.Property("LastWrite") + .HasColumnType("TEXT"); + + b.Property("MediaInfoId") + .HasColumnType("INTEGER"); + + b.HasKey("MediaFileId"); + + b.HasIndex("MediaInfoId"); + + b.ToTable("Files"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.AudioStream", b => + { + b.Property("AudioStreamId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bitrate") + .HasColumnType("INTEGER"); + + b.Property("Channels") + .HasColumnType("INTEGER"); + + b.Property("Codec") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Default") + .HasColumnType("INTEGER"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Forced") + .HasColumnType("INTEGER"); + + b.Property("Index") + .HasColumnType("INTEGER"); + + b.Property("Language") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MediaInfoId") + .HasColumnType("INTEGER"); + + b.Property("MediaStreamType") + .HasColumnType("INTEGER"); + + b.Property("Path") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SampleRate") + .HasColumnType("INTEGER"); + + b.Property("Title") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("AudioStreamId"); + + b.HasIndex("MediaInfoId"); + + b.ToTable("AudioStream"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => + { + b.Property("MediaInfoId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.HasKey("MediaInfoId"); + + b.ToTable("MediaInfo"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.SubtitleStream", b => + { + b.Property("SubtitleStreamId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Codec") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Default") + .HasColumnType("INTEGER"); + + b.Property("Forced") + .HasColumnType("INTEGER"); + + b.Property("Index") + .HasColumnType("INTEGER"); + + b.Property("Language") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MediaInfoId") + .HasColumnType("INTEGER"); + + b.Property("MediaStreamType") + .HasColumnType("INTEGER"); + + b.Property("Path") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Title") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("SubtitleStreamId"); + + b.HasIndex("MediaInfoId"); + + b.ToTable("SubtitleStream"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.VideoStream", b => + { + b.Property("VideoStreamId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bitrate") + .HasColumnType("INTEGER"); + + b.Property("Codec") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Default") + .HasColumnType("INTEGER"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Forced") + .HasColumnType("INTEGER"); + + b.Property("Framerate") + .HasColumnType("REAL"); + + b.Property("Height") + .HasColumnType("INTEGER"); + + b.Property("Index") + .HasColumnType("INTEGER"); + + b.Property("MediaInfoId") + .HasColumnType("INTEGER"); + + b.Property("MediaStreamType") + .HasColumnType("INTEGER"); + + b.Property("Path") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PixelFormat") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Ratio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Rotation") + .HasColumnType("INTEGER"); + + b.Property("Width") + .HasColumnType("INTEGER"); + + b.HasKey("VideoStreamId"); + + b.HasIndex("MediaInfoId"); + + b.ToTable("VideoStream"); + }); + + modelBuilder.Entity("Convertarr.Data.MediaFile", b => + { + b.HasOne("Convertarr.Data.Models.MediaInfo", "MediaInfo") + .WithMany() + .HasForeignKey("MediaInfoId"); + + b.Navigation("MediaInfo"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.AudioStream", b => + { + b.HasOne("Convertarr.Data.Models.MediaInfo", null) + .WithMany("AudioStreams") + .HasForeignKey("MediaInfoId"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.SubtitleStream", b => + { + b.HasOne("Convertarr.Data.Models.MediaInfo", null) + .WithMany("SubtitleStreams") + .HasForeignKey("MediaInfoId"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.VideoStream", b => + { + b.HasOne("Convertarr.Data.Models.MediaInfo", null) + .WithMany("VideoStreams") + .HasForeignKey("MediaInfoId"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => + { + b.Navigation("AudioStreams"); + + b.Navigation("SubtitleStreams"); + + b.Navigation("VideoStreams"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Convertarr.Data/Migrations/20230213211154_Initial.cs b/src/Convertarr.Data/Migrations/20230213211154_Initial.cs new file mode 100644 index 0000000..5fc7953 --- /dev/null +++ b/src/Convertarr.Data/Migrations/20230213211154_Initial.cs @@ -0,0 +1,177 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Convertarr.Data.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "MediaInfo", + columns: table => new + { + MediaInfoId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Duration = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MediaInfo", x => x.MediaInfoId); + }); + + migrationBuilder.CreateTable( + name: "AudioStream", + columns: table => new + { + AudioStreamId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Forced = table.Column(type: "INTEGER", nullable: true), + Title = table.Column(type: "TEXT", nullable: false), + Language = table.Column(type: "TEXT", nullable: false), + Channels = table.Column(type: "INTEGER", nullable: false), + SampleRate = table.Column(type: "INTEGER", nullable: false), + Bitrate = table.Column(type: "INTEGER", nullable: false), + Duration = table.Column(type: "TEXT", nullable: false), + Default = table.Column(type: "INTEGER", nullable: true), + MediaInfoId = table.Column(type: "INTEGER", nullable: true), + Path = table.Column(type: "TEXT", nullable: false), + Index = table.Column(type: "INTEGER", nullable: false), + Codec = table.Column(type: "TEXT", nullable: false), + MediaStreamType = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AudioStream", x => x.AudioStreamId); + table.ForeignKey( + name: "FK_AudioStream_MediaInfo_MediaInfoId", + column: x => x.MediaInfoId, + principalTable: "MediaInfo", + principalColumn: "MediaInfoId"); + }); + + migrationBuilder.CreateTable( + name: "Files", + columns: table => new + { + MediaFileId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + FilePath = table.Column(type: "TEXT", nullable: false), + FileSize = table.Column(type: "INTEGER", nullable: false), + LastWrite = table.Column(type: "TEXT", nullable: false), + MediaInfoId = table.Column(type: "INTEGER", nullable: true), + LastScanned = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Files", x => x.MediaFileId); + table.ForeignKey( + name: "FK_Files_MediaInfo_MediaInfoId", + column: x => x.MediaInfoId, + principalTable: "MediaInfo", + principalColumn: "MediaInfoId"); + }); + + migrationBuilder.CreateTable( + name: "SubtitleStream", + columns: table => new + { + SubtitleStreamId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Language = table.Column(type: "TEXT", nullable: false), + Default = table.Column(type: "INTEGER", nullable: true), + Forced = table.Column(type: "INTEGER", nullable: true), + Title = table.Column(type: "TEXT", nullable: false), + MediaInfoId = table.Column(type: "INTEGER", nullable: true), + Path = table.Column(type: "TEXT", nullable: false), + Index = table.Column(type: "INTEGER", nullable: false), + Codec = table.Column(type: "TEXT", nullable: false), + MediaStreamType = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SubtitleStream", x => x.SubtitleStreamId); + table.ForeignKey( + name: "FK_SubtitleStream_MediaInfo_MediaInfoId", + column: x => x.MediaInfoId, + principalTable: "MediaInfo", + principalColumn: "MediaInfoId"); + }); + + migrationBuilder.CreateTable( + name: "VideoStream", + columns: table => new + { + VideoStreamId = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Rotation = table.Column(type: "INTEGER", nullable: true), + Forced = table.Column(type: "INTEGER", nullable: true), + Default = table.Column(type: "INTEGER", nullable: true), + Bitrate = table.Column(type: "INTEGER", nullable: false), + Ratio = table.Column(type: "TEXT", nullable: false), + Framerate = table.Column(type: "REAL", nullable: false), + Height = table.Column(type: "INTEGER", nullable: false), + Width = table.Column(type: "INTEGER", nullable: false), + Duration = table.Column(type: "TEXT", nullable: false), + PixelFormat = table.Column(type: "TEXT", nullable: false), + MediaInfoId = table.Column(type: "INTEGER", nullable: true), + Path = table.Column(type: "TEXT", nullable: false), + Index = table.Column(type: "INTEGER", nullable: false), + Codec = table.Column(type: "TEXT", nullable: false), + MediaStreamType = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VideoStream", x => x.VideoStreamId); + table.ForeignKey( + name: "FK_VideoStream_MediaInfo_MediaInfoId", + column: x => x.MediaInfoId, + principalTable: "MediaInfo", + principalColumn: "MediaInfoId"); + }); + + migrationBuilder.CreateIndex( + name: "IX_AudioStream_MediaInfoId", + table: "AudioStream", + column: "MediaInfoId"); + + migrationBuilder.CreateIndex( + name: "IX_Files_MediaInfoId", + table: "Files", + column: "MediaInfoId"); + + migrationBuilder.CreateIndex( + name: "IX_SubtitleStream_MediaInfoId", + table: "SubtitleStream", + column: "MediaInfoId"); + + migrationBuilder.CreateIndex( + name: "IX_VideoStream_MediaInfoId", + table: "VideoStream", + column: "MediaInfoId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AudioStream"); + + migrationBuilder.DropTable( + name: "Files"); + + migrationBuilder.DropTable( + name: "SubtitleStream"); + + migrationBuilder.DropTable( + name: "VideoStream"); + + migrationBuilder.DropTable( + name: "MediaInfo"); + } + } +} diff --git a/src/Convertarr.Data/Migrations/ConvertarrContextModelSnapshot.cs b/src/Convertarr.Data/Migrations/ConvertarrContextModelSnapshot.cs index eaa5e8c..8538307 100644 --- a/src/Convertarr.Data/Migrations/ConvertarrContextModelSnapshot.cs +++ b/src/Convertarr.Data/Migrations/ConvertarrContextModelSnapshot.cs @@ -46,19 +46,180 @@ namespace Convertarr.Data.Migrations b.ToTable("Files"); }); + modelBuilder.Entity("Convertarr.Data.Models.AudioStream", b => + { + b.Property("AudioStreamId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bitrate") + .HasColumnType("INTEGER"); + + b.Property("Channels") + .HasColumnType("INTEGER"); + + b.Property("Codec") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Default") + .HasColumnType("INTEGER"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Forced") + .HasColumnType("INTEGER"); + + b.Property("Index") + .HasColumnType("INTEGER"); + + b.Property("Language") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MediaInfoId") + .HasColumnType("INTEGER"); + + b.Property("MediaStreamType") + .HasColumnType("INTEGER"); + + b.Property("Path") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SampleRate") + .HasColumnType("INTEGER"); + + b.Property("Title") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("AudioStreamId"); + + b.HasIndex("MediaInfoId"); + + b.ToTable("AudioStream"); + }); + modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => { b.Property("MediaInfoId") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); + b.Property("Duration") + .HasColumnType("TEXT"); + + b.HasKey("MediaInfoId"); + + b.ToTable("MediaInfo"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.SubtitleStream", b => + { + b.Property("SubtitleStreamId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + b.Property("Codec") .IsRequired() .HasColumnType("TEXT"); - b.HasKey("MediaInfoId"); + b.Property("Default") + .HasColumnType("INTEGER"); - b.ToTable("MediaInfo"); + b.Property("Forced") + .HasColumnType("INTEGER"); + + b.Property("Index") + .HasColumnType("INTEGER"); + + b.Property("Language") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("MediaInfoId") + .HasColumnType("INTEGER"); + + b.Property("MediaStreamType") + .HasColumnType("INTEGER"); + + b.Property("Path") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Title") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("SubtitleStreamId"); + + b.HasIndex("MediaInfoId"); + + b.ToTable("SubtitleStream"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.VideoStream", b => + { + b.Property("VideoStreamId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Bitrate") + .HasColumnType("INTEGER"); + + b.Property("Codec") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Default") + .HasColumnType("INTEGER"); + + b.Property("Duration") + .HasColumnType("TEXT"); + + b.Property("Forced") + .HasColumnType("INTEGER"); + + b.Property("Framerate") + .HasColumnType("REAL"); + + b.Property("Height") + .HasColumnType("INTEGER"); + + b.Property("Index") + .HasColumnType("INTEGER"); + + b.Property("MediaInfoId") + .HasColumnType("INTEGER"); + + b.Property("MediaStreamType") + .HasColumnType("INTEGER"); + + b.Property("Path") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PixelFormat") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Ratio") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Rotation") + .HasColumnType("INTEGER"); + + b.Property("Width") + .HasColumnType("INTEGER"); + + b.HasKey("VideoStreamId"); + + b.HasIndex("MediaInfoId"); + + b.ToTable("VideoStream"); }); modelBuilder.Entity("Convertarr.Data.MediaFile", b => @@ -69,6 +230,36 @@ namespace Convertarr.Data.Migrations b.Navigation("MediaInfo"); }); + + modelBuilder.Entity("Convertarr.Data.Models.AudioStream", b => + { + b.HasOne("Convertarr.Data.Models.MediaInfo", null) + .WithMany("AudioStreams") + .HasForeignKey("MediaInfoId"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.SubtitleStream", b => + { + b.HasOne("Convertarr.Data.Models.MediaInfo", null) + .WithMany("SubtitleStreams") + .HasForeignKey("MediaInfoId"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.VideoStream", b => + { + b.HasOne("Convertarr.Data.Models.MediaInfo", null) + .WithMany("VideoStreams") + .HasForeignKey("MediaInfoId"); + }); + + modelBuilder.Entity("Convertarr.Data.Models.MediaInfo", b => + { + b.Navigation("AudioStreams"); + + b.Navigation("SubtitleStreams"); + + b.Navigation("VideoStreams"); + }); #pragma warning restore 612, 618 } } diff --git a/src/Convertarr.Data/Models/AudioStream.cs b/src/Convertarr.Data/Models/AudioStream.cs new file mode 100644 index 0000000..baa545b --- /dev/null +++ b/src/Convertarr.Data/Models/AudioStream.cs @@ -0,0 +1,45 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Convertarr.Data.Models +{ + public class AudioStream : MediaStream + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int AudioStreamId { get; set; } + + // + // Summary: + // Forced + public int? Forced { get; set; } + // + // Summary: + // Title + public required string Title { get; set; } + // + // Summary: + // Language + public required string Language { get; set; } + // + // Summary: + // Channels + public int Channels { get; set; } + // + // Summary: + // Sample Rate + public int SampleRate { get; set; } + // + // Summary: + // Bitrate + public long Bitrate { get; set; } + // + // Summary: + // Duration + public TimeSpan Duration { get; set; } + // + // Summary: + // Default + public int? Default { get; set; } + } +} \ No newline at end of file diff --git a/src/Convertarr.Data/Models/MediaInfo.cs b/src/Convertarr.Data/Models/MediaInfo.cs index 954675f..a60c10c 100644 --- a/src/Convertarr.Data/Models/MediaInfo.cs +++ b/src/Convertarr.Data/Models/MediaInfo.cs @@ -14,6 +14,14 @@ namespace Convertarr.Data.Models [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int MediaInfoId { get; set; } - public string Codec { get; set; } + // Summary: + // Duration of media + public TimeSpan Duration { get; set;} + + public virtual IEnumerable VideoStreams {get;set;} + + public virtual IEnumerable AudioStreams {get;set;} + + public virtual IEnumerable SubtitleStreams {get;set;} } } diff --git a/src/Convertarr.Data/Models/MediaStream.cs b/src/Convertarr.Data/Models/MediaStream.cs new file mode 100644 index 0000000..95dbb01 --- /dev/null +++ b/src/Convertarr.Data/Models/MediaStream.cs @@ -0,0 +1,22 @@ +namespace Convertarr.Data.Models +{ + public class MediaStream + { + // + // Summary: + // File source of stream + public string Path { get; set; } + // + // Summary: + // Index of stream + public int Index { get; set; } + // + // Summary: + // Format + public string Codec { get; set; } + // + // Summary: + // Codec type + public MediaStreamType MediaStreamType { get; set; } + } +} \ No newline at end of file diff --git a/src/Convertarr.Data/Models/MediaStreamType.cs b/src/Convertarr.Data/Models/MediaStreamType.cs new file mode 100644 index 0000000..496f90c --- /dev/null +++ b/src/Convertarr.Data/Models/MediaStreamType.cs @@ -0,0 +1,21 @@ +namespace Convertarr.Data.Models +{ + // + // Summary: + // Stream type + public enum MediaStreamType + { + // + // Summary: + // Video stream + Video = 0, + // + // Summary: + // Audio stream + Audio = 1, + // + // Summary: + // Subtitle stream + Subtitle = 2 + } +} \ No newline at end of file diff --git a/src/Convertarr.Data/Models/SubtitleStream.cs b/src/Convertarr.Data/Models/SubtitleStream.cs new file mode 100644 index 0000000..39e8c7b --- /dev/null +++ b/src/Convertarr.Data/Models/SubtitleStream.cs @@ -0,0 +1,29 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Convertarr.Data.Models +{ + public class SubtitleStream : MediaStream + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int SubtitleStreamId { get; set; } + + // + // Summary: + // Subtitle language + public required string Language { get; set; } + // + // Summary: + // Default + public int? Default { get; set; } + // + // Summary: + // Forced + public int? Forced { get; set; } + // + // Summary: + // Title + public required string Title { get; set; } + } +} \ No newline at end of file diff --git a/src/Convertarr.Data/Models/VideoStream.cs b/src/Convertarr.Data/Models/VideoStream.cs new file mode 100644 index 0000000..b4f7b1c --- /dev/null +++ b/src/Convertarr.Data/Models/VideoStream.cs @@ -0,0 +1,53 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace Convertarr.Data.Models +{ + public class VideoStream : MediaStream + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int VideoStreamId { get; set; } + + // + // Summary: + // Rotation angle + public int? Rotation { get; set; } + // + // Summary: + // Forced + public int? Forced { get; set; } + // + // Summary: + // Default + public int? Default { get; set; } + // + // Summary: + // Video bitrate + public long Bitrate { get; set; } + // + // Summary: + // Screen ratio + public string Ratio { get; set; } + // + // Summary: + // Frame rate + public double Framerate { get; set; } + // + // Summary: + // Height + public int Height { get; set; } + // + // Summary: + // Width + public int Width { get; set; } + // + // Summary: + // Duration + public TimeSpan Duration { get; set; } + // + // Summary: + // Pixel Format + public required string PixelFormat { get; set; } + } +} \ No newline at end of file diff --git a/src/Convertarr.Web/Convertarr.Web.csproj b/src/Convertarr.Web/Convertarr.Web.csproj index 0f27c42..52df874 100644 --- a/src/Convertarr.Web/Convertarr.Web.csproj +++ b/src/Convertarr.Web/Convertarr.Web.csproj @@ -1,4 +1,4 @@ - + net7.0 @@ -6,8 +6,8 @@ enable Linux . - a6cd9fb8-2c5b-4050-8de6-35b900282e87 false + ddf29b39-9301-478f-82ac-b3dac4be32ac