Adding TPB. Fixes #50

This commit is contained in:
Dessalines 2019-02-19 15:46:28 -08:00
parent 2005b0e5b2
commit 6ae4d8e134
1 changed files with 47 additions and 0 deletions

View File

@ -43,6 +43,7 @@ fn main() {
fetch_cloudflare_cookie();
// torrentz2(save_dir);
thepiratebay(save_dir);
magnetdl(save_dir);
leetx(save_dir);
skytorrents(save_dir);
@ -156,6 +157,52 @@ fn magnetdl(save_dir: &Path) {
}
}
fn thepiratebay(save_dir: &Path) {
let page_limit = 35;
let base_url = "https://thepiratebay.org/browse";
let mut pages: Vec<String> = Vec::new();
let types = [
"100", "101", "102", "103", "104", "199",
"200", "201", "202", "203", "204", "205", "206", "207", "208", "209", "299",
"300", "301", "302", "303", "304", "305", "306", "399",
"400", "401", "402", "403", "404", "405", "406", "407", "408", "499",
"500", "501", "502", "503", "504", "505", "506", "599",
"600", "601", "602", "603", "604", "605", "699"
];
for c_type in types.iter() {
for i in 0..page_limit-1 {
let page = format!("{}/{}/{}/7", base_url, c_type, i);
pages.push(page);
}
}
for page in pages.iter() {
println!("Fetching page {}", page);
let html = match fetch_html(page) {
Ok(t) => t,
_err => continue,
};
let document = Document::from(&html[..]);
for row in document.find(Attr("id", "searchResult").descendant(Name("tr"))) {
let hash_td = match row.find(Name("td").descendant(Name("a"))).nth(3) {
Some(t) => t,
None => continue,
};
let hash = match hash_td.attr("href") {
Some(t) => t.chars().skip(20).take(40).collect(),
None => continue,
};
fetch_torrent(hash, save_dir);
}
}
}
fn skytorrents(save_dir: &Path) {
let page_limit = 100;