Skip to content

Commit

Permalink
- create download folder by year
Browse files Browse the repository at this point in the history
- fix possibly empty name by fallbacking to MovieID
  • Loading branch information
nocturneop15 committed Dec 11, 2023
1 parent 54ddca8 commit bf45c69
Show file tree
Hide file tree
Showing 7 changed files with 337 additions and 9 deletions.
25 changes: 25 additions & 0 deletions Backup/SCCDownloader.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SCCDownloader", "SCCDownloader\SCCDownloader.csproj", "{6AF96A91-4ADF-46BF-9F46-E404A4B702A8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6AF96A91-4ADF-46BF-9F46-E404A4B702A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6AF96A91-4ADF-46BF-9F46-E404A4B702A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6AF96A91-4ADF-46BF-9F46-E404A4B702A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6AF96A91-4ADF-46BF-9F46-E404A4B702A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8238873A-8861-4869-A98A-3A2F375807DF}
EndGlobalSection
EndGlobal
9 changes: 9 additions & 0 deletions SCCDownloader/Models/MediaInfoLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,14 @@ public class MediaInfoLabel
{
[JsonPropertyName("originaltitle")]
public String OriginalTitle { get; set; }

[JsonPropertyName("imdb")]
public String imdb { get; set; }

[JsonPropertyName("csfd")]
public String csfd { get; set; }

[JsonPropertyName("tmdb")]
public String tmdb { get; set; }
}
}
5 changes: 5 additions & 0 deletions SCCDownloader/Movie.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ public class Movie
{
public String Id { get; set; }
public String Name { get; set; }
public String CSFD { get; set; }
public String IMDB { get; set; }
public String TMDB { get; set; }



}
}
24 changes: 17 additions & 7 deletions SCCDownloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace SCCDownoader // Note: actual namespace depends on the project name.
internal class Program
{
static bool enableMediaInfoExtensions = true;
static string DownloadFolder = "Downloads";
//static string DownloadFolder = "Downloads";

static void Main(string[] args)
{
Expand All @@ -21,18 +21,23 @@ static void Main(string[] args)

static async Task MainAsync()
{
if(!Directory.Exists(DownloadFolder))
Console.Write("Zadej pozadovany rok: ");

var yearText = Console.ReadLine();
var year = Int32.Parse(yearText);

var DownloadFolder = yearText;


if (!Directory.Exists(DownloadFolder))
{
Directory.CreateDirectory(DownloadFolder);
}

var sc = new StreamCinema();
var ws = new WebShare();

Console.Write("Zadej pozadovany rok: ");

var yearText = Console.ReadLine();
var year = Int32.Parse(yearText);


var movies = await sc.GetMovieList(year);
if (movies.Any())
Expand Down Expand Up @@ -128,9 +133,14 @@ static int GetResolution(StreamVideoInfo stream)

static String GetFileName(Movie movie, VideoStream stream)
{
// replace empty names with tmdb and fallback to movieID
if (movie.Name.Length == 0) { movie.Name = movie.Id; };

String nameWithoutSpaces = movie.Name.Replace(" ", "_");

string illegal = "\"M\"\\a/ry/ h**ad:>> a\\/:*?\"| li*tt|le|| la\"mb.?";

//string illegal = "\"M\"\\a/ry/ h**ad:>> a\\/:*?\"| li*tt|le|| la\"mb.?"; //asi pokus z testování illegal stringu?

string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());

foreach (char c in invalid)
Expand Down
2 changes: 1 addition & 1 deletion SCCDownloader/SCCDownloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="XAct.Core.PCL" Version="0.0.5014" />
</ItemGroup>

Expand Down
6 changes: 5 additions & 1 deletion SCCDownloader/StreamCinema.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using SCCDownloader.Models;
using System.Net.Http.Json;
using XAct.Resources;

namespace SCCDownloader
{
Expand Down Expand Up @@ -60,7 +61,10 @@ public IEnumerable<Movie> GetMovieList(SearchResponse searchResponse)
new Movie
{
Id = movie.Id,
Name = movie.Source.InfoLabel.OriginalTitle
Name = movie.Source.InfoLabel.OriginalTitle,
CSFD = movie.Source.InfoLabel.csfd,
IMDB = movie.Source.InfoLabel.imdb,
TMDB = movie.Source.InfoLabel.tmdb
}
);
}
Expand Down
Loading

0 comments on commit bf45c69

Please sign in to comment.