diff src/gui/pages/torrents.cc @ 154:d43d68408d3c

dep/animia: fix XnuFdTools also we use anitomy directly now. HG Enter commit message. Lines beginning with 'HG:' are removed.
author Paper <mrpapersonic@gmail.com>
date Wed, 15 Nov 2023 14:14:17 -0500
parents 39521c47c7a3
children bc8d2ccff09c
line wrap: on
line diff
--- a/src/gui/pages/torrents.cc	Wed Nov 15 13:28:18 2023 -0500
+++ b/src/gui/pages/torrents.cc	Wed Nov 15 14:14:17 2023 -0500
@@ -17,6 +17,8 @@
 #include <sstream>
 #include <algorithm>
 
+#include "anitomy/anitomy.h"
+
 /* This file is very, very similar to the anime list page.
 
    It differs from Taiga in that it uses tabs instead of
@@ -71,12 +73,16 @@
 		TorrentModelItem torrent;
 		torrent.SetFilename(item.child_value("title")); /* "title" == filename */
 		{
-			/* Use Anitomy to parse the file's elements (we should *really* not be doing this this way!) */
-			std::unordered_map<std::string, std::string> elements = Track::Media::GetFileElements(torrent.GetFilename());
-			torrent.SetTitle(elements["title"]);
-			torrent.SetEpisode(Strings::RemoveLeadingChars(elements["episode"], '0'));
-			torrent.SetGroup(elements["group"]);
-			torrent.SetResolution(elements["resolution"]);
+			anitomy::Anitomy anitomy;
+			anitomy.Parse(Strings::ToWstring(torrent.GetFilename()));
+
+			const auto& elements = anitomy.elements();
+
+			/* todo: patch Anitomy so that it doesn't use wide strings */
+			torrent.SetTitle(Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle)));
+			torrent.SetEpisode(Strings::RemoveLeadingChars(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)), '0'));
+			torrent.SetGroup(Strings::ToUtf8String(elements.get(anitomy::kElementReleaseGroup)));
+			torrent.SetResolution(Strings::ToUtf8String(elements.get(anitomy::kElementVideoResolution)));
 		}
 		torrent.SetDescription(Strings::TextifySynopsis(item.child_value("description")));
 		{