Skip to content

Commit

Permalink
Ignore file handles with an invalid anime type
Browse files Browse the repository at this point in the history
This fixes the issue where recognition failed due to a linked OP/ED being listed before the actual video file.
  • Loading branch information
erengy committed Oct 31, 2015
1 parent 81c463a commit b7d986b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/track/media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,17 +427,19 @@ bool MediaPlayers::GetTitleFromProcessHandle(HWND hwnd, ULONG process_id,
if (hwnd != nullptr && process_id == 0)
GetWindowThreadProcessId(hwnd, &process_id);

std::vector<std::wstring> files_vector;
std::vector<std::wstring> process_files;

if (!GetProcessFiles(process_id, files_vector))
if (!GetProcessFiles(process_id, process_files))
return false;

for (const auto& path : files_vector) {
for (auto path : process_files) {
if (Meow.IsValidFileExtension(GetFileExtension(path))) {
title = path;
TranslateDeviceName(title);
ConvertToLongPath(title);
break;
TranslateDeviceName(path);
ConvertToLongPath(path);
if (Meow.IsValidAnimeType(path)) {
title = path;
break;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/track/recognition.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Engine {

bool IsBatchRelease(const anime::Episode& episode) const;
bool IsValidAnimeType(const anime::Episode& episode) const;
bool IsValidAnimeType(const std::wstring& path) const;
bool IsValidFileExtension(const anime::Episode& episode) const;
bool IsValidFileExtension(const std::wstring& extension) const;

Expand Down
14 changes: 14 additions & 0 deletions src/track/recognition_validate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ bool Engine::IsValidAnimeType(const anime::Episode& episode) const {
return true;
}

bool Engine::IsValidAnimeType(const std::wstring& path) const {
track::recognition::ParseOptions parse_options;
parse_options.parse_path = true;
parse_options.streaming_media = false;

anime::Episode episode;

if (Parse(path, parse_options, episode))
if (!IsValidAnimeType(episode))
return false;

return true;
}

bool Engine::IsValidFileExtension(const anime::Episode& episode) const {
if (!IsValidFileExtension(episode.file_extension())) {
LOG(LevelDebug, episode.file_name_with_extension());
Expand Down

0 comments on commit b7d986b

Please sign in to comment.