Skip to content

Commit 4480e21

Browse files
committed
added new projects and some base code for persistence
1 parent e5ed4a6 commit 4480e21

12 files changed

+118
-9
lines changed

Tv7Playlist/LoggingEvents.cs Tv7Playlist.Core/LoggingEvents.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
namespace Tv7Playlist
1+
namespace Tv7Playlist.Core
22
{
3-
public class LoggingEvents
3+
public static class LoggingEvents
44
{
55
public const int Startup = 1000;
66
public const int Playlist = 1001;

Tv7Playlist/Parser/IPlaylistParser.cs Tv7Playlist.Core/Parsers/IPlaylistParser.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.IO;
33
using System.Threading.Tasks;
44

5-
namespace Tv7Playlist.Parser
5+
namespace Tv7Playlist.Core.Parsers
66
{
77
public interface IPlaylistParser
88
{

Tv7Playlist/Parser/M3UParser.cs Tv7Playlist.Core/Parsers/M3UParser.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Threading.Tasks;
5-
using Microsoft.EntityFrameworkCore.Internal;
65
using Microsoft.Extensions.Logging;
76

8-
namespace Tv7Playlist.Parser
7+
namespace Tv7Playlist.Core.Parsers
98
{
10-
internal class M3UParser : IPlaylistParser
9+
public class M3UParser : IPlaylistParser
1110
{
1211
private const string ExtInfStartTag = "#EXTINF:";
1312
private const string ExtFileStartTag = "#EXTM3U";
@@ -120,7 +119,9 @@ private ParsedTrack CreateTrack(int currentId, string metaLine, string url)
120119
if (string.IsNullOrWhiteSpace(url))
121120
return null;
122121

123-
var fields = metaLine.Replace(ExtInfStartTag, string.Empty).Split(",");
122+
//TODO: Check line parsing of https://github.com/tellytv/telly/blob/dev/internal/m3uplus/main.go
123+
//format is base for telly to export.
124+
var fields = metaLine.Replace(ExtInfStartTag, string.Empty).Split(',');
124125
var name = fields.Length >= 2 ? fields[1] : $"{currentId}-unknown";
125126

126127
return new ParsedTrack(currentId, name, url);

Tv7Playlist/Parser/ParsedTrack.cs Tv7Playlist.Core/Parsers/ParsedTrack.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using System.Diagnostics;
33

4-
namespace Tv7Playlist.Parser
4+
namespace Tv7Playlist.Core.Parsers
55
{
66
[DebuggerDisplay("ParsedTrack-{Id}(Name:{Name}, Url:{Url})")]
77
public class ParsedTrack
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
9+
</ItemGroup>
10+
11+
</Project>

Tv7Playlist.Data/PlaylistContext.cs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using Microsoft.EntityFrameworkCore;
2+
3+
namespace Tv7Playlist.Data
4+
{
5+
public class PlaylistContext : DbContext
6+
{
7+
public PlaylistContext(DbContextOptions<PlaylistContext> options)
8+
: base(options)
9+
{
10+
}
11+
12+
public DbSet<PlaylistEntry> PlaylistEntries { get; set; }
13+
14+
protected override void OnModelCreating(ModelBuilder modelBuilder)
15+
{
16+
base.OnModelCreating(modelBuilder);
17+
18+
var entityTypeBuilder = modelBuilder.Entity<PlaylistEntry>();
19+
entityTypeBuilder.HasKey(e => e.Id);
20+
entityTypeBuilder.HasAlternateKey(e => e.TrackNumber);
21+
}
22+
}
23+
}

Tv7Playlist.Data/PlaylistEntry.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace Tv7Playlist.Data
4+
{
5+
public class PlaylistEntry
6+
{
7+
public Guid Id { get; set; }
8+
9+
public int TrackNumber { get; set; }
10+
11+
public string Name { get; set; }
12+
13+
public string Url { get; set; }
14+
}
15+
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
9+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0" />
10+
</ItemGroup>
11+
12+
</Project>

Tv7Playlist.sln

+28
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ VisualStudioVersion = 15.0.26124.0
55
MinimumVisualStudioVersion = 15.0.26124.0
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tv7Playlist", "Tv7Playlist\Tv7Playlist.csproj", "{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tv7Playlist.Data", "Tv7Playlist.Data\Tv7Playlist.Data.csproj", "{43C1083D-D092-4CEC-8569-41B7408B5E64}"
9+
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tv7Playlist.Core", "Tv7Playlist.Core\Tv7Playlist.Core.csproj", "{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}"
11+
EndProject
812
Global
913
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1014
Debug|Any CPU = Debug|Any CPU
@@ -30,5 +34,29 @@ Global
3034
{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}.Release|x64.Build.0 = Release|Any CPU
3135
{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}.Release|x86.ActiveCfg = Release|Any CPU
3236
{7B2C4534-318C-4E66-9F6D-F15D1DCAF999}.Release|x86.Build.0 = Release|Any CPU
37+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|x64.ActiveCfg = Debug|Any CPU
40+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|x64.Build.0 = Debug|Any CPU
41+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|x86.ActiveCfg = Debug|Any CPU
42+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Debug|x86.Build.0 = Debug|Any CPU
43+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|Any CPU.ActiveCfg = Release|Any CPU
44+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|Any CPU.Build.0 = Release|Any CPU
45+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|x64.ActiveCfg = Release|Any CPU
46+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|x64.Build.0 = Release|Any CPU
47+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|x86.ActiveCfg = Release|Any CPU
48+
{43C1083D-D092-4CEC-8569-41B7408B5E64}.Release|x86.Build.0 = Release|Any CPU
49+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|x64.ActiveCfg = Debug|Any CPU
52+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|x64.Build.0 = Debug|Any CPU
53+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|x86.ActiveCfg = Debug|Any CPU
54+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Debug|x86.Build.0 = Debug|Any CPU
55+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
56+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|Any CPU.Build.0 = Release|Any CPU
57+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|x64.ActiveCfg = Release|Any CPU
58+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|x64.Build.0 = Release|Any CPU
59+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|x86.ActiveCfg = Release|Any CPU
60+
{F891436B-5075-4CB4-A628-D5DCD8D3CBDD}.Release|x86.Build.0 = Release|Any CPU
3361
EndGlobalSection
3462
EndGlobal

Tv7Playlist/Controllers/PlayListController.cs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.AspNetCore.Mvc;
77
using Microsoft.Extensions.Configuration;
88
using Microsoft.Extensions.Logging;
9+
using Tv7Playlist.Core;
910

1011
namespace Tv7Playlist.Controllers
1112
{

Tv7Playlist/Startup.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
using Microsoft.AspNetCore.Hosting;
33
using Microsoft.AspNetCore.Http;
44
using Microsoft.AspNetCore.Mvc;
5+
using Microsoft.EntityFrameworkCore;
56
using Microsoft.Extensions.Configuration;
67
using Microsoft.Extensions.DependencyInjection;
78
using Microsoft.Extensions.Logging;
9+
using Tv7Playlist.Core;
10+
using Tv7Playlist.Data;
811

912
namespace Tv7Playlist
1013
{
@@ -30,7 +33,10 @@ public void ConfigureServices(IServiceCollection services)
3033
options.MinimumSameSitePolicy = SameSiteMode.None;
3134
});
3235

33-
36+
//TODO: Move to settings to make it configurable within docker.
37+
var connection = "Data Source=playlist.db";
38+
services.AddDbContext<PlaylistContext>(options => options.UseSqlite(connection));
39+
3440
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
3541
}
3642

Tv7Playlist/Tv7Playlist.csproj

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@
99
<ItemGroup>
1010
<PackageReference Include="Microsoft.AspNetCore.App" />
1111
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.0" />
13+
</ItemGroup>
14+
15+
16+
<ItemGroup>
17+
<Folder Include="Parser" />
18+
</ItemGroup>
19+
20+
21+
<ItemGroup>
22+
<ProjectReference Include="..\Tv7Playlist.Core\Tv7Playlist.Core.csproj" />
23+
<ProjectReference Include="..\Tv7Playlist.Data\Tv7Playlist.Data.csproj" />
1224
</ItemGroup>
1325

1426
</Project>

0 commit comments

Comments
 (0)