Skip to content

Commit

Permalink
revert: revert use of transmission-rpc fork
Browse files Browse the repository at this point in the history
  • Loading branch information
Beastwick18 committed Jun 9, 2024
1 parent 775c5ac commit 75dfe74
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 235 deletions.
253 changes: 118 additions & 135 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ strip = true
lto = true

[dependencies]
reqwest = { version = "0.12.4", features = [
# reqwest2 = { package = "reqwest", version = "0.11.27", features = [
# "gzip",
# "rustls-tls",
# "socks",
# "cookies",
# ], default-features = false }
reqwest = { version = "0.11.27", features = [
"gzip",
"rustls-tls",
"socks",
Expand All @@ -36,7 +42,7 @@ scraper = "0.19.0"
regex = "1.10.4"
rss = "2.0.8"
chrono = "0.4.38"
transmission-rpc = { git = "https://github.com/Beastwick18/transmission-rpc", branch = "stable" }
transmission-rpc = { version = "0.4.2" }
open = "5.1.4"
cli-clipboard = "0.4.0"
dirs = "5.0.1"
Expand Down
17 changes: 10 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{pkgs ? import <nixpkgs> {}}:
pkgs.rustPlatform.buildRustPackage rec {
pname = "nyaa";
version = "0.1";
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"transmission-rpc-0.4.2" = "sha256-3na/LUlcCk1MTbFXMtugK8YiLMdwF3m8QnpSKl3B4I8=";
};
};
version = "0.9.0";

# src = fetchFromGitHub {
# owner = "Beastwick18";
# repo = "nyaa";
# rev = "v${version}";
# hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
# };

cargoLock.lockFile = ./Cargo.lock;
src = pkgs.lib.cleanSource ./.;
}
8 changes: 4 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,23 @@ pub enum Client {
#[strum(serialize = "qBittorrent")]
Qbit = 0,

#[serde(rename = "transmission")]
#[serde(rename = "Transmission")]
#[strum(serialize = "Transmission")]
Transmission = 1,

#[serde(rename = "rqbit")]
#[strum(serialize = "rqbit")]
Rqbit = 2,

#[serde(rename = "default_app")]
#[serde(rename = "DefaultApp")]
#[strum(serialize = "Default App")]
DefaultApp = 3,

#[serde(rename = "download")]
#[serde(rename = "DownloadTorrentFile")]
#[strum(serialize = "Download Torrent File")]
Download = 4,

#[serde(rename = "command")]
#[serde(rename = "RunCommand")]
#[strum(serialize = "Run Command")]
Cmd = 5,
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/qbit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct QbitConfig {
pub use_magnet: Option<bool>,
pub savepath: Option<String>,
pub category: Option<String>, // Single category
pub tags: Option<Vec<String>>, // Comma seperated joined
pub tags: Option<Vec<String>>, // Comma separated joined
pub skip_checking: Option<bool>,
pub paused: Option<bool>,
pub create_root_folder: Option<bool>, // root_folder: String
Expand Down
12 changes: 10 additions & 2 deletions src/client/transmission.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
use reqwest::Url;
use serde::{Deserialize, Serialize};
use transmission_rpc::{
types::{BasicAuth, Priority, TorrentAddArgs},
types::{BasicAuth, TorrentAddArgs},
TransClient,
};

use crate::{app::Context, source::Item, util::conv::add_protocol};

use super::{multidownload, ClientConfig, DownloadClient, DownloadError, DownloadResult};

#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
#[repr(i8)]
pub enum Priority {
Low = -1,
Normal = 0,
High = 1,
}

#[derive(Serialize, Deserialize, Clone)]
#[serde(default)]
pub struct TransmissionConfig {
Expand Down Expand Up @@ -49,7 +57,7 @@ impl TransmissionConfig {
paused: self.paused,
peer_limit: self.peer_limit,
download_dir: self.download_dir.to_owned(),
bandwidth_priority: self.bandwidth_priority,
bandwidth_priority: self.bandwidth_priority.map(|r| r as i64),
..Default::default()
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/source.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use std::{collections::HashMap, error::Error, sync::Arc, time::Duration};

use nyaa_html::NyaaTheme;
use reqwest::{cookie::Jar, Proxy};
use serde::{Deserialize, Serialize};
use strum::{Display, VariantArray};
use sukebei_nyaa::SukebeiTheme;
use torrent_galaxy::TgxTheme;

use crate::{
app::{Context, LoadType, Widgets},
Expand Down Expand Up @@ -44,6 +47,16 @@ pub enum SourceResponse {
Captcha(Box<dyn StatefulProtocol>),
}

#[derive(Serialize, Deserialize, Clone, Copy, Default)]
pub struct SourceTheme {
#[serde(default)]
pub nyaa: NyaaTheme,
#[serde(default)]
pub sukebei: SukebeiTheme,
#[serde(default, rename = "torrentgalaxy")]
pub tgx: TgxTheme,
}

#[derive(Serialize, Deserialize, Clone, Default)]
#[serde(default)]
pub struct SourceConfig {
Expand Down
34 changes: 17 additions & 17 deletions src/source/nyaa_html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,38 +474,38 @@ impl Source for NyaaHtmlSource {
}
"Anime" => {
10 => ("Ani", "All Anime", "AllAnime", fg);
12 => ("Sub", "English Translated", "AnimeEnglishTranslated", nyaa.cat.anime_english_translated);
13 => ("Sub", "Non-English Translated", "AnimeNonEnglishTranslated", nyaa.cat.anime_non_english_translated);
14 => ("Raw", "Raw", "AnimeRaw", nyaa.cat.anime_raw);
11 => ("AMV", "Anime Music Video", "AnimeMusicVideo", nyaa.cat.anime_music_video);
12 => ("Sub", "English Translated", "AnimeEnglishTranslated", source.nyaa.cat.anime_english_translated);
13 => ("Sub", "Non-English Translated", "AnimeNonEnglishTranslated", source.nyaa.cat.anime_non_english_translated);
14 => ("Raw", "Raw", "AnimeRaw", source.nyaa.cat.anime_raw);
11 => ("AMV", "Anime Music Video", "AnimeMusicVideo", source.nyaa.cat.anime_music_video);
}
"Audio" => {
20 => ("Aud", "All Audio", "AllAudio", fg);
21 => ("Aud", "Lossless", "AudioLossless", nyaa.cat.audio_lossless);
22 => ("Aud", "Lossy", "AudioLossy", nyaa.cat.audio_lossy);
21 => ("Aud", "Lossless", "AudioLossless", source.nyaa.cat.audio_lossless);
22 => ("Aud", "Lossy", "AudioLossy", source.nyaa.cat.audio_lossy);
}
"Literature" => {
30 => ("Lit", "All Literature", "AllLiterature", fg);
31 => ("Lit", "English Translated", "LitEnglishTranslated", nyaa.cat.literature_english_translated);
32 => ("Lit", "Non-English Translated", "LitNonEnglishTranslated", nyaa.cat.literature_non_english_translated);
33 => ("Lit", "Raw", "LitRaw", nyaa.cat.literature_raw);
31 => ("Lit", "English Translated", "LitEnglishTranslated", source.nyaa.cat.literature_english_translated);
32 => ("Lit", "Non-English Translated", "LitNonEnglishTranslated", source.nyaa.cat.literature_non_english_translated);
33 => ("Lit", "Raw", "LitRaw", source.nyaa.cat.literature_raw);
}
"Live Action" => {
40 => ("Liv", "All Live Action", "AllLiveAction", fg);
41 => ("Liv", "English Translated", "LiveEnglishTranslated", nyaa.cat.live_english_translated);
43 => ("Liv", "Non-English Translated", "LiveNonEnglishTranslated", nyaa.cat.live_non_english_translated);
42 => ("Liv", "Idol/Promo Video", "LiveIdolPromoVideo", nyaa.cat.live_idol_promo_video);
44 => ("Liv", "Raw", "LiveRaw", nyaa.cat.live_raw);
41 => ("Liv", "English Translated", "LiveEnglishTranslated", source.nyaa.cat.live_english_translated);
43 => ("Liv", "Non-English Translated", "LiveNonEnglishTranslated", source.nyaa.cat.live_non_english_translated);
42 => ("Liv", "Idol/Promo Video", "LiveIdolPromoVideo", source.nyaa.cat.live_idol_promo_video);
44 => ("Liv", "Raw", "LiveRaw", source.nyaa.cat.live_raw);
}
"Pictures" => {
50 => ("Pic", "All Pictures", "AllPictures", fg);
51 => ("Pic", "Graphics", "PicGraphics", nyaa.cat.picture_graphics);
52 => ("Pic", "Photos", "PicPhotos", nyaa.cat.picture_photos);
51 => ("Pic", "Graphics", "PicGraphics", source.nyaa.cat.picture_graphics);
52 => ("Pic", "Photos", "PicPhotos", source.nyaa.cat.picture_photos);
}
"Software" => {
60 => ("Sof", "All Software", "AllSoftware", fg);
61 => ("Sof", "Applications", "SoftApplications", nyaa.cat.software_applications);
62 => ("Sof", "Games", "SoftGames", nyaa.cat.software_games);
61 => ("Sof", "Applications", "SoftApplications", source.nyaa.cat.software_applications);
62 => ("Sof", "Games", "SoftGames", source.nyaa.cat.software_games);
}
};
SourceInfo {
Expand Down
14 changes: 7 additions & 7 deletions src/source/sukebei_nyaa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,16 @@ impl Source for SukebeiHtmlSource {
}
"Art" => {
10 => ("Art", "All Art", "AllArt", fg);
11 => ("Ani", "Anime", "ArtAnime", sukebei.cat.art_anime);
12 => ("Dou", "Doujinshi", "ArtDoujinshi", sukebei.cat.art_doujinshi);
13 => ("Gam", "Games", "ArtGames", sukebei.cat.art_games);
14 => ("Man", "Manga", "ArtManga", sukebei.cat.art_manga);
15 => ("Pic", "Pictures", "ArtPictures", sukebei.cat.art_pictures);
11 => ("Ani", "Anime", "ArtAnime", source.sukebei.cat.art_anime);
12 => ("Dou", "Doujinshi", "ArtDoujinshi", source.sukebei.cat.art_doujinshi);
13 => ("Gam", "Games", "ArtGames", source.sukebei.cat.art_games);
14 => ("Man", "Manga", "ArtManga", source.sukebei.cat.art_manga);
15 => ("Pic", "Pictures", "ArtPictures", source.sukebei.cat.art_pictures);
}
"Real Life" => {
20 => ("Rea", "All Real Life", "AllReal", fg);
21 => ("Pho", "Photobooks and Pictures", "RealPhotos", sukebei.cat.real_photos);
22 => ("Vid", "Videos", "RealVideos", sukebei.cat.real_videos);
21 => ("Pho", "Photobooks and Pictures", "RealPhotos", source.sukebei.cat.real_photos);
22 => ("Vid", "Videos", "RealVideos", source.sukebei.cat.real_videos);
}
};
SourceInfo {
Expand Down
74 changes: 37 additions & 37 deletions src/source/torrent_galaxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,43 +649,43 @@ impl Source for TorrentGalaxyHtmlSource {

fn info() -> SourceInfo {
let cats = cats! {
"All Categories" => { 0 => ("---", "All Categories", "AllCategories", tgx.cat.all_categories); }
"Movies" => {3 => ("4kM", "4K UHD Movies", "4kMovies", tgx.cat.movies_4k);
46 => ("Bly", "Bollywood", "Bollywood Movies", tgx.cat.movies_bollywood);
45 => ("Cam", "Cam/TS", "CamMovies", tgx.cat.movies_cam);
42 => ("HdM", "HD Movies", "HdMovies", tgx.cat.movies_hd);
4 => ("PkM", "Movie Packs", "PackMovies", tgx.cat.movies_pack);
1 => ("SdM", "SD Movies", "SdMovies", tgx.cat.movies_sd);}
"TV" => {41 => ("HdT", "TV HD", "HdTV", tgx.cat.tv_hd);
5 => ("SdT", "TV SD", "SdTV", tgx.cat.tv_sd);
11 => ("4kT", "TV 4k", "4kTV", tgx.cat.tv_4k);
6 => ("PkT", "TV Packs", "PacksTV", tgx.cat.tv_pack);
7 => ("Spo", "Sports", "SportsTV", tgx.cat.tv_sports);}
"Anime" => {28 => ("Ani", "All Anime", "Anime", tgx.cat.anime);}
"Apps" => {20 => ("Mob", "Mobile Apps", "AppsMobile", tgx.cat.apps_mobile);
21 => ("App", "Other Apps", "AppsOther", tgx.cat.apps_other);
18 => ("Win", "Windows Apps", "AppsWindows", tgx.cat.apps_windows);}
"Books" => {13 => ("Abk", "Audiobooks", "Audiobooks", tgx.cat.audiobooks);
19 => ("Com", "Comics", "Comics", tgx.cat.comics);
12 => ("Ebk", "Ebooks", "Ebooks", tgx.cat.ebooks);
14 => ("Edu", "Educational", "Educational", tgx.cat.educational);
15 => ("Mag", "Magazines", "Magazines", tgx.cat.magazines);}
"Documentaries" => {9 => ("Doc", "All Documentaries", "Documentaries", tgx.cat.documentaries);}
"Games" => {10 => ("Wgm", "Windows Games", "WindowsGames", tgx.cat.games_windows);
43 => ("Ogm", "Other Games", "OtherGames", tgx.cat.games_other);}
"Music" => {22 => ("Alb", "Music Albums", "AlbumsMusic", tgx.cat.music_albums);
26 => ("Dis", "Music Discography", "DiscographyMusic", tgx.cat.music_discography);
23 => ("Los", "Music Lossless", "LosslessMusic", tgx.cat.music_lossless);
25 => ("MV ", "Music Video", "MusicVideo", tgx.cat.music_video);
24 => ("Sin", "Music Singles", "SinglesMusic", tgx.cat.music_singles);}
"Other" => {17 => ("Aud", "Other Audio", "AudioOther", tgx.cat.audio_other);
40 => ("Pic", "Other Pictures", "PicturesOther", tgx.cat.pictures_other);
37 => ("Tra", "Other Training", "TrainingOther", tgx.cat.training_other);
33 => ("Oth", "Other", "Other", tgx.cat.other);}
"XXX" => {48 => ("4kX", "XXX 4k", "4kXXX", tgx.cat.xxx_4k);
35 => ("HdX", "XXX HD", "HdXXX", tgx.cat.xxx_hd);
47 => ("MsX", "XXX Misc", "MiscXXX", tgx.cat.xxx_misc);
34 => ("SdX", "XXX SD", "SdXXX", tgx.cat.xxx_sd);}
"All Categories" => { 0 => ("---", "All Categories", "AllCategories", source.tgx.cat.all_categories); }
"Movies" => {3 => ("4kM", "4K UHD Movies", "4kMovies", source.tgx.cat.movies_4k);
46 => ("Bly", "Bollywood", "Bollywood Movies", source.tgx.cat.movies_bollywood);
45 => ("Cam", "Cam/TS", "CamMovies", source.tgx.cat.movies_cam);
42 => ("HdM", "HD Movies", "HdMovies", source.tgx.cat.movies_hd);
4 => ("PkM", "Movie Packs", "PackMovies", source.tgx.cat.movies_pack);
1 => ("SdM", "SD Movies", "SdMovies", source.tgx.cat.movies_sd);}
"TV" => {41 => ("HdT", "TV HD", "HdTV", source.tgx.cat.tv_hd);
5 => ("SdT", "TV SD", "SdTV", source.tgx.cat.tv_sd);
11 => ("4kT", "TV 4k", "4kTV", source.tgx.cat.tv_4k);
6 => ("PkT", "TV Packs", "PacksTV", source.tgx.cat.tv_pack);
7 => ("Spo", "Sports", "SportsTV", source.tgx.cat.tv_sports);}
"Anime" => {28 => ("Ani", "All Anime", "Anime", source.tgx.cat.anime);}
"Apps" => {20 => ("Mob", "Mobile Apps", "AppsMobile", source.tgx.cat.apps_mobile);
21 => ("App", "Other Apps", "AppsOther", source.tgx.cat.apps_other);
18 => ("Win", "Windows Apps", "AppsWindows", source.tgx.cat.apps_windows);}
"Books" => {13 => ("Abk", "Audiobooks", "Audiobooks", source.tgx.cat.audiobooks);
19 => ("Com", "Comics", "Comics", source.tgx.cat.comics);
12 => ("Ebk", "Ebooks", "Ebooks", source.tgx.cat.ebooks);
14 => ("Edu", "Educational", "Educational", source.tgx.cat.educational);
15 => ("Mag", "Magazines", "Magazines", source.tgx.cat.magazines);}
"Documentaries" => {9 => ("Doc", "All Documentaries", "Documentaries", source.tgx.cat.documentaries);}
"Games" => {10 => ("Wgm", "Windows Games", "WindowsGames", source.tgx.cat.games_windows);
43 => ("Ogm", "Other Games", "OtherGames", source.tgx.cat.games_other);}
"Music" => {22 => ("Alb", "Music Albums", "AlbumsMusic", source.tgx.cat.music_albums);
26 => ("Dis", "Music Discography", "DiscographyMusic", source.tgx.cat.music_discography);
23 => ("Los", "Music Lossless", "LosslessMusic", source.tgx.cat.music_lossless);
25 => ("MV ", "Music Video", "MusicVideo", source.tgx.cat.music_video);
24 => ("Sin", "Music Singles", "SinglesMusic", source.tgx.cat.music_singles);}
"Other" => {17 => ("Aud", "Other Audio", "AudioOther", source.tgx.cat.audio_other);
40 => ("Pic", "Other Pictures", "PicturesOther", source.tgx.cat.pictures_other);
37 => ("Tra", "Other Training", "TrainingOther", source.tgx.cat.training_other);
33 => ("Oth", "Other", "Other", source.tgx.cat.other);}
"XXX" => {48 => ("4kX", "XXX 4k", "4kXXX", source.tgx.cat.xxx_4k);
35 => ("HdX", "XXX HD", "HdXXX", source.tgx.cat.xxx_hd);
47 => ("MsX", "XXX Misc", "MiscXXX", source.tgx.cat.xxx_misc);
34 => ("SdX", "XXX SD", "SdXXX", source.tgx.cat.xxx_sd);}
};
SourceInfo {
cats,
Expand Down
28 changes: 6 additions & 22 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ use indexmap::IndexMap;
use ratatui::{style::Color, widgets::BorderType};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use crate::{
app::Context,
collection, config,
source::{nyaa_html::NyaaTheme, sukebei_nyaa::SukebeiTheme, torrent_galaxy::TgxTheme},
};
use crate::{app::Context, collection, config, source::SourceTheme};

#[derive(Clone, Serialize, Deserialize)]
pub struct Theme {
Expand Down Expand Up @@ -42,11 +38,7 @@ pub struct Theme {
pub error: Color,

#[serde(default)]
pub nyaa: NyaaTheme,
#[serde(default)]
pub sukebei: SukebeiTheme,
#[serde(default, rename = "torrent_galaxy")]
pub tgx: TgxTheme,
pub source: SourceTheme,
}

pub fn load_user_themes(ctx: &mut Context, config_path: PathBuf) -> Result<(), String> {
Expand Down Expand Up @@ -142,9 +134,7 @@ impl Default for Theme {
solid_fg: Color::Black,
success: Color::Green,
error: Color::Red,
nyaa: Default::default(),
sukebei: Default::default(),
tgx: Default::default(),
source: Default::default(),
}
}
}
Expand All @@ -170,9 +160,7 @@ pub fn default_themes() -> IndexMap<String, Theme> {
solid_bg: Color::Rgb(139, 233, 253),
success: Color::Rgb(80, 250, 123),
error: Color::Rgb(255, 85, 85),
nyaa: Default::default(),
sukebei: Default::default(),
tgx: Default::default(),
source: Default::default(),
},
"Gruvbox".to_owned() => Theme {
name: "Gruvbox".to_owned(),
Expand All @@ -186,9 +174,7 @@ pub fn default_themes() -> IndexMap<String, Theme> {
solid_fg: Color::Rgb(235, 219, 178),
success: Color::Rgb(152, 151, 26),
error: Color::Rgb(204, 36, 29),
nyaa: Default::default(),
sukebei: Default::default(),
tgx: Default::default(),
source: Default::default(),
},
"Catppuccin Macchiato".to_owned() => Theme {
name: "Catppuccin Macchiato".to_owned(),
Expand All @@ -202,9 +188,7 @@ pub fn default_themes() -> IndexMap<String, Theme> {
solid_fg: Color::Rgb(24, 25, 38),
success: Color::Rgb(166, 218, 149),
error: Color::Rgb(237, 135, 150),
nyaa: Default::default(),
sukebei: Default::default(),
tgx: Default::default(),
source: Default::default(),
},
]
}
3 changes: 2 additions & 1 deletion src/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ use unicode_width::UnicodeWidthStr as _;

use crate::{app::Context, style, theme::Theme};

pub mod batch;
#[cfg(feature = "captcha")]
pub mod captcha;

pub mod batch;
pub mod category;
pub mod clients;
pub mod filter;
Expand Down

0 comments on commit 75dfe74

Please sign in to comment.