diff options
| -rwxr-xr-x | news | bin | 702152 -> 702728 bytes | |||
| -rw-r--r-- | src/RSS.cpp | 8 | ||||
| -rw-r--r-- | src/RSS.hpp | 3 | ||||
| -rw-r--r-- | src/main.cpp | 4 |
4 files changed, 9 insertions, 6 deletions
| Binary files differ diff --git a/src/RSS.cpp b/src/RSS.cpp index 20c809f..a5c8b12 100644 --- a/src/RSS.cpp +++ b/src/RSS.cpp @@ -67,7 +67,9 @@ void RSS::parse(std::string contents) { // std::cout << "starting tokenization..." << std::endl; if (contents.length() == 0) return; try { - auto leaf = XML_leaf(contents).GetChild("channel"); + auto leaf = XML_leaf(contents); + if (leaf.Name != "channel") + leaf = leaf.GetChild("channel"); if (leaf.Raw == "<>") throw new std::runtime_error("The feed does not contain <channel> element"); @@ -76,8 +78,8 @@ void RSS::parse(std::string contents) { auto items = leaf.GetChildren("item"); for (auto item : items) Entries.push_back(RSS_Entry(item)); - } catch (const char *err) { - std::cout << "Failed to parse feed '" << URL << "' :" << err << std::endl; + } catch (std::exception& err) { + std::cout << "Failed to parse feed '" << URL << "' :" << err.what() << std::endl; return; } } diff --git a/src/RSS.hpp b/src/RSS.hpp index c4a5b2c..8a0292b 100644 --- a/src/RSS.hpp +++ b/src/RSS.hpp @@ -106,8 +106,8 @@ class XML_leaf { static std::string trimSpaces(std::string raw) { auto outp = std::regex_replace(raw, std::regex("\n"), ""); - outp = std::regex_replace(outp, std::regex("> <"), "><"); outp = std::regex_replace(outp, std::regex(" +"), " "); + outp = std::regex_replace(outp, std::regex("> <"), "><"); return outp; } @@ -130,6 +130,7 @@ class XML_leaf { outp.push_back(raw.substr(idx, (next_idx - idx) + 1)); idx = next_idx + 1; } + // std::cout << "Tokenization done" << '\n'; return outp; }; diff --git a/src/main.cpp b/src/main.cpp index cabe6dd..737ef8a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,8 +33,8 @@ int main() { // std::cout << "URL: " << src.GetValue() << std::endl; RSS(src.GetValue()).print_latest(span); } - } catch (char *ex) { - std::cout << "failed to read config file: " << ex << std::endl; + } catch (std::exception& err) { + std::cout << "failed to read config file: " << err.what() << std::endl; return 1; } |
