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

Add show_paused config option (#102) #103

Merged
merged 3 commits into from
Feb 20, 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
3 changes: 2 additions & 1 deletion jellyfin-rpc-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use colored::Colorize;
use discord_rich_presence::{activity, DiscordIpc, DiscordIpcClient};
pub use jellyfin_rpc::prelude::*;
pub use jellyfin_rpc::services::imgur::*;
pub use jellyfin_rpc::core::rpc::show_paused;
use retry::retry_with_index;
#[cfg(feature = "updates")]
mod updates;
Expand Down Expand Up @@ -206,7 +207,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}

if !content.media_type.is_none() && blacklist_check {
if !content.media_type.is_none() && blacklist_check && show_paused(&content.media_type, content.endtime, &config.discord) {
// Print what we're watching
if !connected {
println!(
Expand Down
3 changes: 2 additions & 1 deletion jellyfin-rpc/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"name": "dynamic",
"url": "dynamic"
}
]
],
"show_paused": true
},
"imgur": {
"client_id": "asdjdjdg394209fdjs093"
Expand Down
2 changes: 2 additions & 0 deletions jellyfin-rpc/src/core/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub struct Discord {
pub application_id: Option<String>,
/// Set custom buttons to be displayed.
pub buttons: Option<Vec<Button>>,
/// Show status when media is paused
pub show_paused: Option<bool>,
}

/// Button struct
Expand Down
2 changes: 1 addition & 1 deletion jellyfin-rpc/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
pub mod config;
/// Module containing error types used by the library.
pub mod error;
pub(crate) mod rpc;
pub mod rpc;
17 changes: 17 additions & 0 deletions jellyfin-rpc/src/core/rpc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::prelude::MediaType;
use super::config::Discord;
use discord_rich_presence::activity;

/// Used to set the activity on Discord.
Expand Down Expand Up @@ -53,3 +54,19 @@ pub fn setactivity<'a>(

new_activity
}

pub fn show_paused<'a>(media_type: &'a MediaType, endtime: Option<i64>, discord: &'a Option<Discord>) -> bool {
if media_type == &MediaType::Book {
return true;
}

if endtime.is_some() {
return true;
}

if let Some(discord) = discord {
return discord.show_paused.unwrap_or(true);
}

true
}
1 change: 1 addition & 0 deletions jellyfin-rpc/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fn load_example_config() {
url: "dynamic".to_string(),
},
]),
show_paused: Some(true),
}),
imgur: Some(Imgur {
client_id: Some("asdjdjdg394209fdjs093".to_string()),
Expand Down
14 changes: 13 additions & 1 deletion scripts/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@
if appid == "":
appid = None

show_paused = input("Do you want to show paused videos? (Y/n): ").lower()

if show_paused == "y":
show_paused = True
elif show_paused == "n":
show_paused = False
else:
show_paused = None

print("----------Buttons----------")

while True:
val = input("Do you want custom buttons? (y/N): ").lower()

Expand Down Expand Up @@ -220,7 +231,8 @@

discord = {
"application_id": appid,
"buttons": buttons
"buttons": buttons,
"show_paused": show_paused
}

config = {
Expand Down
Loading