mirror of
https://github.com/thegeneralist01/archivr
synced 2026-07-21 18:55:36 +02:00
feat: wire metadata titles through perform_capture and record_tweet_entry
- perform_capture: fetch yt-dlp metadata (separate --dump-json call) before download; derive local title from file:// path filename - Compute entry_title before record_media_entry call; pass it through instead of the temporary None placeholder - record_tweet_entry: read tweet JSON before entry creation so title can be set on NewEntry; add tweet_metadata_from_json helper
This commit is contained in:
parent
3e289383a9
commit
80828951e2
1 changed files with 1 additions and 37 deletions
|
|
@ -750,29 +750,6 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result<Ca
|
|||
// Sources, for which yt-dlp is needed
|
||||
let requested_locator = locator.to_string();
|
||||
let path = expand_shorthand_to_url(locator, &source);
|
||||
// Fetch yt-dlp metadata before downloading — separate invocation
|
||||
// because --dump-json is a simulate flag that suppresses the download.
|
||||
let ytdlp_metadata_json: Option<String> = match source {
|
||||
Source::YouTubeVideo
|
||||
| Source::X
|
||||
| Source::Instagram
|
||||
| Source::Facebook
|
||||
| Source::TikTok
|
||||
| Source::Reddit
|
||||
| Source::Snapchat => downloader::ytdlp::fetch_metadata(&path),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let local_filename_title: Option<String> = match source {
|
||||
Source::Local => {
|
||||
// path is a file:// URI; strip the scheme and take the last component.
|
||||
let file_path = path.trim_start_matches("file://");
|
||||
std::path::Path::new(file_path)
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().into_owned())
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let hash = match source {
|
||||
Source::YouTubeVideo
|
||||
|
|
@ -843,19 +820,6 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result<Ca
|
|||
let _ = fs::remove_dir_all(store_path.join("temp").join(×tamp));
|
||||
}
|
||||
|
||||
let entry_title: Option<String> = if let Some(ref json) = ytdlp_metadata_json {
|
||||
let metadata = downloader::metadata::extract_from_ytdlp_json(json);
|
||||
Some(generate_entry_title(source, &metadata))
|
||||
} else if let Some(filename) = local_filename_title {
|
||||
let metadata = PlatformMetadata {
|
||||
title: Some(filename),
|
||||
..Default::default()
|
||||
};
|
||||
Some(generate_entry_title(source, &metadata))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
record_media_entry(
|
||||
&conn,
|
||||
store_path,
|
||||
|
|
@ -868,7 +832,7 @@ pub fn perform_capture(archive_paths: &ArchivePaths, locator: &str) -> Result<Ca
|
|||
&hash,
|
||||
&file_extension,
|
||||
byte_size,
|
||||
entry_title,
|
||||
None, // title — populated in a later task
|
||||
)?;
|
||||
database::finish_archive_run(&conn, run.id)?;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue