mirror of
https://github.com/YGGverse/rssto.git
synced 2026-03-31 17:15:29 +00:00
remove extra lines
This commit is contained in:
parent
a4bbb0be68
commit
0e6ee4cb22
2 changed files with 20 additions and 7 deletions
|
|
@ -14,6 +14,7 @@ anyhow = "1.0"
|
|||
chrono = "^0.4.20"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
log = "0.4"
|
||||
regex = "1.12"
|
||||
reqwest = { version = "0.12", features = ["blocking"] }
|
||||
rss = "2.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
|
|
|
|||
18
src/main.rs
18
src/main.rs
|
|
@ -61,6 +61,7 @@ fn crawl(feed: &Feed) -> Result<()> {
|
|||
let channel = Channel::read_from(&get(feed.url.as_str())?.bytes()?[..])?;
|
||||
let channel_items = channel.items();
|
||||
let channel_items_limit = feed.list_items_limit.unwrap_or(channel_items.len());
|
||||
let regex = regex::Regex::new(r"\n{2,}").unwrap();
|
||||
|
||||
for template in &feed.templates {
|
||||
let root = PathBuf::from(template);
|
||||
|
|
@ -106,14 +107,25 @@ fn crawl(feed: &Feed) -> Result<()> {
|
|||
.iter()
|
||||
.take(channel_items_limit)
|
||||
.map(|i| {
|
||||
index_item
|
||||
.replace("{title}", &strip_tags(i.title().unwrap_or_default()))
|
||||
regex
|
||||
.replace_all(
|
||||
&index_item
|
||||
.replace(
|
||||
"{title}",
|
||||
&strip_tags(i.title().unwrap_or_default()),
|
||||
)
|
||||
.replace(
|
||||
"{description}",
|
||||
&strip_tags(i.description().unwrap_or_default()),
|
||||
)
|
||||
.replace("{link}", i.link().unwrap_or_default())
|
||||
.replace("{pub_date}", &time(i.pub_date(), &feed.pub_date_format))
|
||||
.replace(
|
||||
"{pub_date}",
|
||||
&time(i.pub_date(), &feed.pub_date_format),
|
||||
),
|
||||
"\n",
|
||||
)
|
||||
.to_string()
|
||||
})
|
||||
.collect::<String>(),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue