Skip to content

Commit 37c620b

Browse files
jamerstTyr3al
authored andcommitted
Minor bug fixes:
Handle cases where shows do not have any episode groups Fix chosen episode group not being selected Fix error when finding cover filename Increment config version
1 parent b5ae654 commit 37c620b

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"args": ["/home/james/Desktop/test", "--extended-tagging"],
1515
"cwd": "${workspaceFolder}/AutoTag.CLI",
1616
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
17-
"console": "internalConsole",
17+
"console": "externalTerminal",
1818
"stopAtEntry": false
1919
},
2020
{

AutoTag.Core/AutoTagConfig.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace AutoTag.Core;
22
public class AutoTagConfig
33
{
44
public enum Modes { TV, Movie };
5-
public const int CurrentVer = 9;
5+
public const int CurrentVer = 10;
66
public int ConfigVer { get; set; } = CurrentVer;
77
public Modes Mode { get; set; } = Modes.TV;
88
public bool ManualMode { get; set; } = false;

AutoTag.Core/TV/ShowResults.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public ShowResults(SearchTv tvSearchResult)
3131
public static implicit operator ShowResults(SearchTv tv) => new(tv);
3232

3333
/// <summary>
34-
/// Generates <see cref="ShowResults"/> list from any <see cref="SearchTv"/> enumerable
34+
/// Generates <see cref="ShowResults"/> list from any <see cref="SearchTv"/> enumerable
3535
/// </summary>
3636
/// <param name="results">Result from tmdb client</param>
3737
public static List<ShowResults> FromSearchResults(IEnumerable<SearchTv> results)
3838
{
3939
return results.Select(result => (ShowResults)result).ToList();
4040
}
4141

42-
42+
4343
/// <summary>
4444
/// Add optional episode group to tv result
4545
/// </summary>
@@ -71,7 +71,7 @@ public bool TryGetMapping(int seasonNumber, int episodeNumber, out (int season,
7171

7272
return false;
7373
}
74-
74+
7575
/// <summary>
7676
/// Tries to generate mapping table between TMDB standard sorting of show
7777
/// and the given Episode Group

AutoTag.Core/TV/TVProcessor.cs

+26-20
Original file line numberDiff line numberDiff line change
@@ -121,34 +121,40 @@ FileWriter writer
121121
{
122122
_shows.Add(episodeData.SeriesName, ShowResults.FromSearchResults(seriesResults));
123123
}
124-
124+
125125
if (config.EpisodeGroup)
126126
{
127127
var seriesResult = _shows[episodeData.SeriesName][0];
128128
var tvShow = await _tmdb.GetTvShowAsync(seriesResult.TvSearchResult.Id, TvShowMethods.EpisodeGroups);
129129
var groups = tvShow.EpisodeGroups;
130-
131-
var chosenGroup = selectResult(groups.Results.Select(group =>
132-
($"[{group.Type}] {group.Name}", $"S: {group.GroupCount} E: {group.EpisodeCount}")).ToList());
133-
134-
if (chosenGroup.HasValue)
130+
131+
if (groups.Results.Any())
135132
{
136-
var groupInfo = await _tmdb.GetTvEpisodeGroupsAsync(groups.Results[0].Id, config.Language);
137-
if (!seriesResult.AddEpisodeGroup(groupInfo))
133+
var chosenGroup = selectResult(groups.Results.Select(group =>
134+
($"[{group.Type}] {group.Name}", $"{group.GroupCount} seasons, {group.EpisodeCount} episodes")).ToList());
135+
136+
if (chosenGroup.HasValue)
138137
{
139-
setStatus($"Error: Episode Group {groupInfo.Name} is not containing Seasons or Volumes! ", MessageType.Error);
140-
result.Success = false;
141-
return false;
138+
var groupInfo = await _tmdb.GetTvEpisodeGroupsAsync(groups.Results[chosenGroup.Value].Id, config.Language);
139+
if (!seriesResult.AddEpisodeGroup(groupInfo))
140+
{
141+
setStatus($"Error: Unable to parse required information from episode group {groupInfo.Name}", MessageType.Error);
142+
result.Success = false;
143+
return false;
144+
}
145+
}
146+
else
147+
{
148+
setStatus("File skipped", MessageType.Warning);
149+
return true;
142150
}
143151
}
144152
else
145153
{
146-
setStatus("File skipped", MessageType.Warning);
147-
return true;
154+
setStatus($"No episode groups found for series", MessageType.Warning);
148155
}
149156
}
150157
}
151-
152158

153159
// try searching for each series search result
154160
foreach (var show in _shows[episodeData.SeriesName])
@@ -157,8 +163,8 @@ FileWriter writer
157163

158164
var lookupSeason = episodeData.Season;
159165
var lookupEpisode = episodeData.Episode;
160-
161-
if(config.EpisodeGroup)
166+
167+
if (show.EpisodeGroupMappingTable != null)
162168
{
163169
if (!show.TryGetMapping(episodeData.Season, episodeData.Episode, out var groupNumbering))
164170
{
@@ -168,7 +174,7 @@ FileWriter writer
168174
lookupSeason = groupNumbering!.Value.season;
169175
lookupEpisode = groupNumbering.Value.episode;
170176
}
171-
177+
172178
result.Id = showData.Id;
173179
result.SeriesName = showData.Name;
174180

@@ -242,7 +248,7 @@ FileWriter writer
242248
if (seriesImages.Posters.Any())
243249
{
244250
var bestVotedImage = seriesImages.Posters.OrderByDescending(p => p.VoteAverage).First();
245-
251+
246252
result.CoverURL = $"https://image.tmdb.org/t/p/original/{bestVotedImage.FilePath}";
247253
_seasonPosters.Add((result.SeriesName, result.Season), result.CoverURL);
248254
}
@@ -255,13 +261,13 @@ FileWriter writer
255261
}
256262
#endregion
257263

258-
result.CoverFilename = result.CoverURL?.Split('/')[-1];
264+
result.CoverFilename = result.CoverURL?.Split('/')[^1];
259265

260266
var taggingSuccess = await writer.WriteAsync(file, result, setPath, setStatus, config);
261267

262268
return taggingSuccess && result.Success && result.Complete;
263269
}
264-
270+
265271
private static double SeriesNameSimilarity(string parsedName, string seriesName)
266272
{
267273
if (seriesName.ToLower().Contains(parsedName.ToLower()))

0 commit comments

Comments
 (0)