added new projects and some base code for persistence
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
namespace Tv7Playlist
|
namespace Tv7Playlist.Core
|
||||||
{
|
{
|
||||||
public class LoggingEvents
|
public static class LoggingEvents
|
||||||
{
|
{
|
||||||
public const int Startup = 1000;
|
public const int Startup = 1000;
|
||||||
public const int Playlist = 1001;
|
public const int Playlist = 1001;
|
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Tv7Playlist.Parser
|
namespace Tv7Playlist.Core.Parsers
|
||||||
{
|
{
|
||||||
public interface IPlaylistParser
|
public interface IPlaylistParser
|
||||||
{
|
{
|
@@ -2,12 +2,11 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore.Internal;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Tv7Playlist.Parser
|
namespace Tv7Playlist.Core.Parsers
|
||||||
{
|
{
|
||||||
internal class M3UParser : IPlaylistParser
|
public class M3UParser : IPlaylistParser
|
||||||
{
|
{
|
||||||
private const string ExtInfStartTag = "#EXTINF:";
|
private const string ExtInfStartTag = "#EXTINF:";
|
||||||
private const string ExtFileStartTag = "#EXTM3U";
|
private const string ExtFileStartTag = "#EXTM3U";
|
||||||
@@ -120,7 +119,9 @@ namespace Tv7Playlist.Parser
|
|||||||
if (string.IsNullOrWhiteSpace(url))
|
if (string.IsNullOrWhiteSpace(url))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var fields = metaLine.Replace(ExtInfStartTag, string.Empty).Split(",");
|
//TODO: Check line parsing of https://github.com/tellytv/telly/blob/dev/internal/m3uplus/main.go
|
||||||
|
//format is base for telly to export.
|
||||||
|
var fields = metaLine.Replace(ExtInfStartTag, string.Empty).Split(',');
|
||||||
var name = fields.Length >= 2 ? fields[1] : $"{currentId}-unknown";
|
var name = fields.Length >= 2 ? fields[1] : $"{currentId}-unknown";
|
||||||
|
|
||||||
return new ParsedTrack(currentId, name, url);
|
return new ParsedTrack(currentId, name, url);
|
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Tv7Playlist.Parser
|
namespace Tv7Playlist.Core.Parsers
|
||||||
{
|
{
|
||||||
[DebuggerDisplay("ParsedTrack-{Id}(Name:{Name}, Url:{Url})")]
|
[DebuggerDisplay("ParsedTrack-{Id}(Name:{Name}, Url:{Url})")]
|
||||||
public class ParsedTrack
|
public class ParsedTrack
|
11
Tv7Playlist.Core/Tv7Playlist.Core.csproj
Normal file
11
Tv7Playlist.Core/Tv7Playlist.Core.csproj
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
23
Tv7Playlist.Data/PlaylistContext.cs
Normal file
23
Tv7Playlist.Data/PlaylistContext.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace Tv7Playlist.Data
|
||||||
|
{
|
||||||
|
public class PlaylistContext : DbContext
|
||||||
|
{
|
||||||
|
public PlaylistContext(DbContextOptions<PlaylistContext> options)
|
||||||
|
: base(options)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public DbSet<PlaylistEntry> PlaylistEntries { get; set; }
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
|
var entityTypeBuilder = modelBuilder.Entity<PlaylistEntry>();
|
||||||
|
entityTypeBuilder.HasKey(e => e.Id);
|
||||||
|
entityTypeBuilder.HasAlternateKey(e => e.TrackNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
Tv7Playlist.Data/PlaylistEntry.cs
Normal file
15
Tv7Playlist.Data/PlaylistEntry.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Tv7Playlist.Data
|
||||||
|
{
|
||||||
|
public class PlaylistEntry
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public int TrackNumber { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public string Url { get; set; }
|
||||||
|
}
|
||||||
|
}
|
12
Tv7Playlist.Data/Tv7Playlist.Data.csproj
Normal file
12
Tv7Playlist.Data/Tv7Playlist.Data.csproj
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@@ -5,6 +5,10 @@ VisualStudioVersion = 15.0.26124.0
|
|||||||
MinimumVisualStudioVersion = 15.0.26124.0
|
MinimumVisualStudioVersion = 15.0.26124.0
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tv7Playlist", "Tv7Playlist\Tv7Playlist.csproj", "{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tv7Playlist", "Tv7Playlist\Tv7Playlist.csproj", "{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tv7Playlist.Data", "Tv7Playlist.Data\Tv7Playlist.Data.csproj", "{43C1083D-D092-4CEC-8569-41B7408B5E64}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tv7Playlist.Core", "Tv7Playlist.Core\Tv7Playlist.Core.csproj", "{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -30,5 +34,29 @@ Global
|
|||||||
{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}.Release|x64.Build.0 = Release|Any CPU
|
{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}.Release|x86.ActiveCfg = Release|Any CPU
|
{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}.Release|x86.Build.0 = Release|Any CPU
|
{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Tv7Playlist.Core;
|
||||||
|
|
||||||
namespace Tv7Playlist.Controllers
|
namespace Tv7Playlist.Controllers
|
||||||
{
|
{
|
||||||
|
@@ -2,9 +2,12 @@
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Tv7Playlist.Core;
|
||||||
|
using Tv7Playlist.Data;
|
||||||
|
|
||||||
namespace Tv7Playlist
|
namespace Tv7Playlist
|
||||||
{
|
{
|
||||||
@@ -30,7 +33,10 @@ namespace Tv7Playlist
|
|||||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//TODO: Move to settings to make it configurable within docker.
|
||||||
|
var connection = "Data Source=playlist.db";
|
||||||
|
services.AddDbContext<PlaylistContext>(options => options.UseSqlite(connection));
|
||||||
|
|
||||||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -9,6 +9,18 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Parser" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Tv7Playlist.Core\Tv7Playlist.Core.csproj" />
|
||||||
|
<ProjectReference Include="..\Tv7Playlist.Data\Tv7Playlist.Data.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Reference in New Issue
Block a user