mirror of
https://gitlab.com/Anson-Projects/projects.git
synced 2025-09-19 03:52:37 +00:00
Compare commits
21 Commits
a6dd33ce5f
...
ghost-cont
Author | SHA1 | Date | |
---|---|---|---|
85adfdf067 | |||
c9e0264208 | |||
d3966eaf53 | |||
21ad5cb862 | |||
9e2596c070 | |||
f93746e2c0 | |||
ae1be54f8f | |||
e479c96e44 | |||
890775b2bc | |||
788052233a | |||
1a4773b3ef | |||
84f4e48386 | |||
52229040c6 | |||
b70c57e23e | |||
f6532e4fb6 | |||
0675f1f1b7 | |||
b5a4b33b56 | |||
9fc6a9bae1 | |||
05474b986d | |||
cdb96a50b7 | |||
e233a96f55 |
@@ -5,6 +5,8 @@ publish:
|
||||
- cd ./ghost-upload
|
||||
- cargo run
|
||||
needs:
|
||||
- pages
|
||||
- job: pages
|
||||
optional: true
|
||||
rules:
|
||||
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
|
||||
- if: "$CI_COMMIT_BRANCH == 'ghost-content-extraction'" # Allow testing on this branch
|
||||
|
@@ -228,10 +228,47 @@ async fn get_existing_post_id(slug: &str, token: &str) -> Option<String> {
|
||||
}
|
||||
|
||||
async fn fetch_feed(url: &str) -> Vec<Entry> {
|
||||
let content = reqwest::get(url).await.unwrap().text().await.unwrap();
|
||||
|
||||
let feed = parser::parse(content.as_bytes()).unwrap();
|
||||
println!("Fetching RSS feed from: {}", url);
|
||||
|
||||
let response = reqwest::get(url).await;
|
||||
let response = match response {
|
||||
Ok(resp) => resp,
|
||||
Err(e) => {
|
||||
println!("Failed to fetch RSS feed: {}", e);
|
||||
return vec![];
|
||||
}
|
||||
};
|
||||
|
||||
if !response.status().is_success() {
|
||||
println!("RSS feed request failed with status: {}", response.status());
|
||||
return vec![];
|
||||
}
|
||||
|
||||
let content = match response.text().await {
|
||||
Ok(text) => text,
|
||||
Err(e) => {
|
||||
println!("Failed to read RSS feed content: {}", e);
|
||||
return vec![];
|
||||
}
|
||||
};
|
||||
|
||||
if content.trim().is_empty() {
|
||||
println!("RSS feed content is empty");
|
||||
return vec![];
|
||||
}
|
||||
|
||||
println!("RSS feed content preview: {}", &content[..content.len().min(200)]);
|
||||
|
||||
let feed = match parser::parse(content.as_bytes()) {
|
||||
Ok(f) => f,
|
||||
Err(e) => {
|
||||
println!("Failed to parse RSS feed: {:?}", e);
|
||||
println!("Feed content starts with: {}", &content[..content.len().min(500)]);
|
||||
return vec![];
|
||||
}
|
||||
};
|
||||
|
||||
println!("Successfully parsed RSS feed with {} entries", feed.entries.len());
|
||||
feed.entries
|
||||
}
|
||||
|
||||
@@ -328,6 +365,13 @@ async fn main() {
|
||||
|
||||
// Prepare the post data
|
||||
let entries = fetch_feed(feed).await;
|
||||
|
||||
if entries.is_empty() {
|
||||
println!("No entries found in RSS feed or feed parsing failed. Exiting.");
|
||||
return;
|
||||
}
|
||||
|
||||
println!("Processing {} entries from RSS feed", entries.len());
|
||||
|
||||
let post_exists_futures = entries.into_iter().map(|entry| {
|
||||
let entry_clone = entry.clone();
|
||||
|
Reference in New Issue
Block a user