Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
153:bd439dd6ffc5 | 154:d43d68408d3c |
---|---|
15 #include <QDebug> | 15 #include <QDebug> |
16 #include <iostream> | 16 #include <iostream> |
17 #include <sstream> | 17 #include <sstream> |
18 #include <algorithm> | 18 #include <algorithm> |
19 | 19 |
20 #include "anitomy/anitomy.h" | |
21 | |
20 /* This file is very, very similar to the anime list page. | 22 /* This file is very, very similar to the anime list page. |
21 | 23 |
22 It differs from Taiga in that it uses tabs instead of | 24 It differs from Taiga in that it uses tabs instead of |
23 those "groups", but those are custom painted and a pain in the ass to | 25 those "groups", but those are custom painted and a pain in the ass to |
24 maintain over multiple platforms. */ | 26 maintain over multiple platforms. */ |
69 /* this is just an rss parser; it should be in a separate class... */ | 71 /* this is just an rss parser; it should be in a separate class... */ |
70 for (pugi::xml_node item : doc.child("rss").child("channel").children("item")) { | 72 for (pugi::xml_node item : doc.child("rss").child("channel").children("item")) { |
71 TorrentModelItem torrent; | 73 TorrentModelItem torrent; |
72 torrent.SetFilename(item.child_value("title")); /* "title" == filename */ | 74 torrent.SetFilename(item.child_value("title")); /* "title" == filename */ |
73 { | 75 { |
74 /* Use Anitomy to parse the file's elements (we should *really* not be doing this this way!) */ | 76 anitomy::Anitomy anitomy; |
75 std::unordered_map<std::string, std::string> elements = Track::Media::GetFileElements(torrent.GetFilename()); | 77 anitomy.Parse(Strings::ToWstring(torrent.GetFilename())); |
76 torrent.SetTitle(elements["title"]); | 78 |
77 torrent.SetEpisode(Strings::RemoveLeadingChars(elements["episode"], '0')); | 79 const auto& elements = anitomy.elements(); |
78 torrent.SetGroup(elements["group"]); | 80 |
79 torrent.SetResolution(elements["resolution"]); | 81 /* todo: patch Anitomy so that it doesn't use wide strings */ |
82 torrent.SetTitle(Strings::ToUtf8String(elements.get(anitomy::kElementAnimeTitle))); | |
83 torrent.SetEpisode(Strings::RemoveLeadingChars(Strings::ToUtf8String(elements.get(anitomy::kElementEpisodeNumber)), '0')); | |
84 torrent.SetGroup(Strings::ToUtf8String(elements.get(anitomy::kElementReleaseGroup))); | |
85 torrent.SetResolution(Strings::ToUtf8String(elements.get(anitomy::kElementVideoResolution))); | |
80 } | 86 } |
81 torrent.SetDescription(Strings::TextifySynopsis(item.child_value("description"))); | 87 torrent.SetDescription(Strings::TextifySynopsis(item.child_value("description"))); |
82 { | 88 { |
83 /* Parse description... */ | 89 /* Parse description... */ |
84 enum class Keys { SIZE, AUTHORIZED, SUBMITTER, COMMENT }; | 90 enum class Keys { SIZE, AUTHORIZED, SUBMITTER, COMMENT }; |