Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix torrent-csv search #218

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/search_providers/test_data/torrent-csv-empty.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[]
{"torrents":[],"next":0}
2 changes: 1 addition & 1 deletion src/search_providers/test_data/torrent-csv.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"infohash":"b30d51525dc734253b83ca93b36557383236dde7","name":"[Judas] Chainsaw Man - S01E03.mkv","size_bytes":329532449,"created_unix":1673548000,"seeders":164,"leechers":4,"completed":15911,"scraped_date":1673548046},{"infohash":"d172992f571ee727e87f1a7ad639dfeb2cb1ec03","name":"Chainsaw Man S01E03 1080p WEB H264-SENPAI","size_bytes":1460288881,"created_unix":1666714811,"seeders":140,"leechers":24,"completed":12529,"scraped_date":1673467058},{"infohash":"ecfa64d4389f13f178b7ece65d9b2cc043f69e95","name":"Chainsaw Man S01E03 1080p HEVC x265-MeGusta","size_bytes":214685450,"created_unix":1666754411,"seeders":30,"leechers":6,"completed":4132,"scraped_date":1673215422},{"infohash":"72dfee89c8a68fe5a84011fd887bd4f4c5d4e270","name":"Chainsaw.Man.S01E03.2022.1080p.CR.WEBRip.10bits.x265-Rapta","size_bytes":171711031,"created_unix":1666725025,"seeders":22,"leechers":6,"completed":3438,"scraped_date":1673212856},{"infohash":"df11b37a7868cb28759d5d795a73ee9c32449176","name":"Chainsaw Man - S01E03.mkv","size_bytes":1462394163,"created_unix":1674427204,"seeders":16,"leechers":3,"completed":2290,"scraped_date":1674427243},{"infohash":"305d87ed2d41fea3e8cd3b4dfa4f360d589d0d92","name":"[ Torrent911.tv ] Chainsaw.Man.S01E03.SUBFRENCH.WEB-DL.CR.1080p.x264.AAC-Tsundere-Raws.mp4","size_bytes":1457284184,"created_unix":1674973632,"seeders":9,"leechers":3,"completed":1026,"scraped_date":1674973760},{"infohash":"c1ebbf1467e8a644dff1744b0104ea59f74c6c51","name":"Chainsaw.Man.S01E03.WEB-DL.AAC2.0.x264.DUAL-www.animestotais.xyz","size_bytes":1479971839,"created_unix":1673473486,"seeders":8,"leechers":1,"completed":445,"scraped_date":1673473504},{"infohash":"8e661e6567ea35c67dbf2ebc42d7544ec2a8041d","name":"Chainsaw Man S01E03 XviD-AFG","size_bytes":250892780,"created_unix":1666722010,"seeders":5,"leechers":1,"completed":2960,"scraped_date":1673213415}]
{"torrents":[{"infohash":"b30d51525dc734253b83ca93b36557383236dde7","name":"[Judas] Chainsaw Man - S01E03.mkv","size_bytes":329532449,"created_unix":1673548000,"seeders":164,"leechers":4,"completed":15911,"scraped_date":1673548046},{"infohash":"d172992f571ee727e87f1a7ad639dfeb2cb1ec03","name":"Chainsaw Man S01E03 1080p WEB H264-SENPAI","size_bytes":1460288881,"created_unix":1666714811,"seeders":140,"leechers":24,"completed":12529,"scraped_date":1673467058},{"infohash":"ecfa64d4389f13f178b7ece65d9b2cc043f69e95","name":"Chainsaw Man S01E03 1080p HEVC x265-MeGusta","size_bytes":214685450,"created_unix":1666754411,"seeders":30,"leechers":6,"completed":4132,"scraped_date":1673215422},{"infohash":"72dfee89c8a68fe5a84011fd887bd4f4c5d4e270","name":"Chainsaw.Man.S01E03.2022.1080p.CR.WEBRip.10bits.x265-Rapta","size_bytes":171711031,"created_unix":1666725025,"seeders":22,"leechers":6,"completed":3438,"scraped_date":1673212856},{"infohash":"df11b37a7868cb28759d5d795a73ee9c32449176","name":"Chainsaw Man - S01E03.mkv","size_bytes":1462394163,"created_unix":1674427204,"seeders":16,"leechers":3,"completed":2290,"scraped_date":1674427243},{"infohash":"305d87ed2d41fea3e8cd3b4dfa4f360d589d0d92","name":"[ Torrent911.tv ] Chainsaw.Man.S01E03.SUBFRENCH.WEB-DL.CR.1080p.x264.AAC-Tsundere-Raws.mp4","size_bytes":1457284184,"created_unix":1674973632,"seeders":9,"leechers":3,"completed":1026,"scraped_date":1674973760},{"infohash":"c1ebbf1467e8a644dff1744b0104ea59f74c6c51","name":"Chainsaw.Man.S01E03.WEB-DL.AAC2.0.x264.DUAL-www.animestotais.xyz","size_bytes":1479971839,"created_unix":1673473486,"seeders":8,"leechers":1,"completed":445,"scraped_date":1673473504},{"infohash":"8e661e6567ea35c67dbf2ebc42d7544ec2a8041d","name":"Chainsaw Man S01E03 XviD-AFG","size_bytes":250892780,"created_unix":1666722010,"seeders":5,"leechers":1,"completed":2960,"scraped_date":1673213415}],"next":1}
11 changes: 9 additions & 2 deletions src/search_providers/torrent_csv_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ use serde::Deserialize;

use std::error::Error;

#[derive(Debug, Deserialize)]
pub struct Response {
pub torrents: Vec<Entry>,
pub next: u64,
Comment on lines +19 to +20
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the next field is for pagination? I guess it's OK to just return the first page of results.

}

#[derive(Debug, Deserialize)]
pub struct Entry {
pub infohash: String,
Expand Down Expand Up @@ -73,9 +79,10 @@ impl SearchProvider for TorrentCsvSearch {
}

fn parse_torrent_csv(content: &str) -> Result<Vec<Torrent>, Box<dyn Error + Send + Sync>> {
let entries: Vec<Entry> = serde_json::from_str(content)?;
let res: Response = serde_json::from_str(content)?;

let results = entries
let results = res
.torrents
.iter()
.map(|entry| Torrent {
name: entry.name.clone(),
Expand Down
Loading