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

ARM support, ommiting episode names and adding a "0" prefix to episode and season numbers #111

Merged
merged 10 commits into from
Apr 14, 2024
88 changes: 88 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,94 @@ jobs:
name: linux
path: target/release/jellyfin-rpc-x86_64-linux

ubuntu-arm32:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: armv7-unknown-linux-gnueabihf
default: true
override: true

- name: Install ARM32 gcc
run: sudo apt install gcc-arm-linux-gnueabihf -y

- name: Cache target folder
uses: actions/cache@v3
env:
cache-name: target-folder
with:
path: target
key: arm32-linux-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
arm32-linux-

- name: Build for ARM32 Linux
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target armv7-unknown-linux-gnueabihf --workspace --locked --release

- name: Rename binary
run: mv target/armv7-unknown-linux-gnueabihf/release/jellyfin-rpc target/armv7-unknown-linux-gnueabihf/release/jellyfin-rpc-arm32-linux

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: linux-arm32
path: target/armv7-unknown-linux-gnueabihf/release/jellyfin-rpc-arm32-linux

ubuntu-arm64:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-unknown-linux-gnu
default: true
override: true

- name: Install ARM64 gcc
run: sudo apt install gcc-aarch64-linux-gnu -y

- name: Cache target folder
uses: actions/cache@v3
env:
cache-name: target-folder
with:
path: target
key: arm64-linux-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
arm64-linux-

- name: Build for ARM64 Linux
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target aarch64-unknown-linux-gnu --workspace --locked --release

- name: Rename binary
run: mv target/aarch64-unknown-linux-gnu/release/jellyfin-rpc target/aarch64-unknown-linux-gnu/release/jellyfin-rpc-arm64-linux

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: linux-arm64
path: target/aarch64-unknown-linux-gnu/release/jellyfin-rpc-arm64-linux

windows:
runs-on: windows-latest

Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,100 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

ubuntu-arm32:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: armv7-unknown-linux-gnueabihf
default: true
override: true

- name: Install ARM32 gcc
run: sudo apt install gcc-arm-linux-gnueabihf -y

- name: Cache target folder
uses: actions/cache@v3
env:
cache-name: target-folder
with:
path: target
key: arm32-linux-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
arm32-linux-

- name: Build for ARM32 Linux
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target armv7-unknown-linux-gnueabihf --workspace --locked --release

- name: Rename binary
run: mv target/armv7-unknown-linux-gnueabihf/release/jellyfin-rpc target/armv7-unknown-linux-gnueabihf/release/jellyfin-rpc-arm32-linux

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
target/armv7-unknown-linux-gnueabihf/release/jellyfin-rpc-arm32-linux
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

ubuntu-arm64:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install latest rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: aarch64-unknown-linux-gnu
default: true
override: true

- name: Install ARM64 gcc
run: sudo apt install gcc-aarch64-linux-gnu -y

- name: Cache target folder
uses: actions/cache@v3
env:
cache-name: target-folder
with:
path: target
key: arm64-linux-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
arm64-linux-

- name: Build for ARM64 Linux
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --target aarch64-unknown-linux-gnu --workspace --locked --release

- name: Rename binary
run: mv target/aarch64-unknown-linux-gnu/release/jellyfin-rpc target/aarch64-unknown-linux-gnu/release/jellyfin-rpc-arm64-linux

- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
target/aarch64-unknown-linux-gnu/release/jellyfin-rpc-arm64-linux
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

windows:
runs-on: windows-latest

Expand Down
3 changes: 3 additions & 0 deletions jellyfin-rpc/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"separator": "-"
},
"self_signed_cert": false,
"show_simple": false,
"append_prefix": false,
"add_divider": false,
"_comment": "the 4 lines below and this line arent needed and should be removed, by default nothing will display if these are present",
"blacklist": {
"media_types": ["music", "movie", "episode", "livetv"],
Expand Down
9 changes: 9 additions & 0 deletions jellyfin-rpc/src/core/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ pub struct Jellyfin {
pub blacklist: Option<Blacklist>,
/// Self signed certificate option
pub self_signed_cert: Option<bool>,
/// Simple episode name
pub show_simple: Option<bool>,
/// Add "0" before season/episode number if lower than 10.
pub append_prefix: Option<bool>,
/// Add a divider between numbers
pub add_divider: Option<bool>
}

/// Username of the person that info should be gathered from.
Expand Down Expand Up @@ -168,6 +174,9 @@ impl Default for Config {
music: None,
blacklist: None,
self_signed_cert: None,
show_simple: Some(false),
append_prefix: Some(false),
add_divider: Some(false)
},
discord: None,
imgur: None,
Expand Down
45 changes: 37 additions & 8 deletions jellyfin-rpc/src/services/jellyfin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,21 +223,50 @@ impl Content {
After the for loop is complete we remove the trailing ", " because it looks bad in the presence.
Then we send it off as a Vec<String> with the external urls and the end timer to the main loop.
*/
let name = now_playing_item["Name"].as_str()?;
let name = if config.jellyfin.show_simple? {
""
} else {
now_playing_item["Name"].as_str()?
};
if now_playing_item["Type"].as_str()? == "Episode" {
let season = now_playing_item["ParentIndexNumber"].to_string();
let first_episode_number = now_playing_item["IndexNumber"].to_string();
let mut state = "S".to_owned() + &season + "E" + &first_episode_number;
let season = now_playing_item["ParentIndexNumber"].as_i64().unwrap_or(0) as i32;
let first_episode_number = now_playing_item["IndexNumber"].as_i64().unwrap_or(0) as i32;
let mut state;
if config.jellyfin.append_prefix? {
if config.jellyfin.add_divider? {
state = format!("S{:02} - E{:02}", season, first_episode_number);
} else {
state = format!("S{:02}E{:02}", season, first_episode_number);
}

} else {
if config.jellyfin.add_divider? {
state = format!("S{} - E{}", season, first_episode_number);
} else {
state = format!("S{}E{}", season, first_episode_number);
}
};

if season == *"null" {
state = "E".to_owned() + &first_episode_number;
if season.to_string() == *"null" {
if config.jellyfin.append_prefix? {
state = format!("E{:02}", first_episode_number);
} else {
state = format!("E{}", first_episode_number);
};
}

if now_playing_item.get("IndexNumberEnd").is_some() {
state += &("-".to_string() + &now_playing_item["IndexNumberEnd"].to_string());
let end_number = if config.jellyfin.append_prefix? {
format!("{:02}", now_playing_item["IndexNumberEnd"])
} else {
format!("{}", now_playing_item["IndexNumberEnd"])
};
state += &(" - ".to_string() + &end_number);
}

state += &(" ".to_string() + name);
if !config.jellyfin.show_simple? {
state += &(" ".to_string() + name);
}
content.media_type(MediaType::Episode);
content.details(now_playing_item["SeriesName"].as_str()?.to_string());
content.state_message(state);
Expand Down
6 changes: 6 additions & 0 deletions jellyfin-rpc/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ fn load_example_config() {
libraries: Some(vec!["Anime".to_string(), "Anime Movies".to_string()]),
}),
self_signed_cert: Some(false),
show_simple: Some(false),
append_prefix: Some(false),
add_divider: Some(false)
},
discord: Some(Discord {
application_id: Some("1053747938519679018".to_string()),
Expand Down Expand Up @@ -63,6 +66,9 @@ fn try_get_content() {
music: None,
blacklist: None,
self_signed_cert: None,
show_simple: Some(false),
append_prefix: Some(false),
add_divider: Some(false)
},
discord: None,
imgur: None,
Expand Down
48 changes: 46 additions & 2 deletions scripts/installer.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
from time import sleep
import sys

# Covering all the possible arch, aarch variations
def is_arm64():
return True if 'aarch64' in platform.machine().lower() or 'armv8' in platform.machine().lower() else False

def is_arm32():
return True if 'aarch' in platform.machine().lower() or 'arm' in platform.machine().lower() else False

path = ""

if platform.system() != "Windows":
Expand Down Expand Up @@ -130,13 +137,43 @@

break

show_simple = input("Do you want to show episode names in RPC? (Y/n): ").lower()

if show_simple == "y":
show_simple = False
elif show_simple == "n":
show_simple = True
else:
show_simple = False

append_prefix = input("Do you want to add a leading 0 to season and episode numbers? (Y/n): ").lower()

if append_prefix == "y":
append_prefix = True
elif append_prefix == "n":
append_prefix = False
else:
append_prefix = False

add_divider = input("Do you want to add a divider between numbers, ex. S01 - E01? (Y/n): ").lower()

if add_divider == "y":
add_divider = True
elif add_divider == "n":
add_divider = False
else:
add_divider = False

jellyfin = {
"url": url,
"api_key": api_key,
"username": username,
"music": music,
"blacklist": blacklist,
"self_signed_cert": self_signed_cert
"self_signed_cert": self_signed_cert,
"show_simple": show_simple,
"append_prefix": append_prefix,
"add_divider": add_divider
}

print("----------Discord----------")
Expand Down Expand Up @@ -359,8 +396,15 @@
print("If needed, you can run Jellyfin RPC at any time by running 'jellyfin-rpc' in a terminal.")
break
else:
if is_arm64():
linux_binary = "jellyfin-rpc-arm64-linux"
elif is_arm32():
linux_binary = "jellyfin-rpc-arm32-linux"
else :
linux_binary = "jellyfin-rpc-x86_64-linux"

subprocess.run(["mkdir", "-p", os.environ["HOME"].removesuffix("/") + "/.local/bin"])
subprocess.run(["curl", "-o", os.environ["HOME"].removesuffix("/") + "/.local/bin/jellyfin-rpc", "-L", "https://github.com/Radiicall/jellyfin-rpc/releases/latest/download/jellyfin-rpc-x86_64-linux"])
subprocess.run(["curl", "-o", os.environ["HOME"].removesuffix("/") + "/.local/bin/jellyfin-rpc", "-L", f"https://github.com/Radiicall/jellyfin-rpc/releases/latest/download/{linux_binary}"])
subprocess.run(["chmod", "+x", os.environ["HOME"].removesuffix("/") + "/.local/bin/jellyfin-rpc"])

if os.environ.get("XDG_CONFIG_HOME"):
Expand Down
Loading