Skip to content

Commit

Permalink
Merge pull request #53 from LSchallot/development
Browse files Browse the repository at this point in the history
0.6.0 Development
  • Loading branch information
LSchallot authored Jan 4, 2025
2 parents 12d5805 + e7bae18 commit a0385be
Show file tree
Hide file tree
Showing 10 changed files with 441 additions and 55 deletions.
92 changes: 91 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 21 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
[package]
name = "jellyroller"
version = "0.5.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.3.19", features = ["derive"] }
confy = "0.6.0"
serde = "1.0.144"
serde_derive = "1.0.144"
serde_json = "1.0.85"
reqwest = { version = "0.12.4", features = ["blocking", "json", "rustls-tls"], default-features = false }
rpassword = "7.3.1"
url = "2.2.2"
comfy-table = "7.0.1"
image = "0.25.1"
base64 = "0.22.1"
[package]
name = "jellyroller"
version = "0.6.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
chrono = "0.4.39"
clap = { version = "4.3.19", features = ["derive"] }
confy = "0.6.0"
serde = "1.0.144"
serde_derive = "1.0.144"
serde_json = "1.0.85"
reqwest = { version = "0.12.4", features = ["blocking", "json", "rustls-tls"], default-features = false }
rpassword = "7.3.1"
url = "2.2.2"
comfy-table = "7.0.1"
image = "0.25.1"
base64 = "0.22.1"
csv = "1.3.1"
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Any previous user auth tokens will be converted to an API key upon next executio
## Usage Information

```
jellyroller 0.5.0
jellyroller 0.6.0
A CLI controller for managing Jellyfin
Usage: jellyroller.exe <COMMAND>
Expand Down Expand Up @@ -46,6 +46,10 @@ Commands:
generate-report Generate a report for an issue
update-metadata Updates metadata of specified id with metadata provided by specified file
register-library Registers a new library
register-repository Registers a new Plugin Repository
get-repositories Lists all current repositories
get-packages Lists all available packages
install-package Installs the specified package
help Print this message or the help of the given subcommand(s)
Options:
Expand Down
9 changes: 6 additions & 3 deletions src/entities/device_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ pub struct DeviceDetails {
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "LastUserName")]
pub lastusername: String
pub lastusername: String,
#[serde(rename = "DateLastActivity")]
pub lastactivity: String
}

impl DeviceDetails {
pub fn new(id: String, name: String, lastusername: String) -> DeviceDetails {
pub fn new(id: String, name: String, lastusername: String, lastactivity: String) -> DeviceDetails {
DeviceDetails{
id,
name,
lastusername
lastusername,
lastactivity
}
}

Expand Down
47 changes: 39 additions & 8 deletions src/entities/media_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,18 +1057,49 @@ pub struct CurrentProgram {
}

impl MediaRoot {
pub fn table_print(media: MediaRoot) {
pub fn table_print(media: MediaRoot, table_columns: &Vec<String>) {
let mut table = Table::new();
table
.set_content_arrangement(ContentArrangement::Dynamic)
.set_header(vec!["Name", "ID", "Type"]);
.set_header(table_columns);
for media_item in media.items {
table.add_row(vec![
&media_item.name,
&media_item.id,
&media_item.type_field
]);
table.add_row(
build_table_row(&media_item, table_columns)
);
}
println!("{table}");
}
}

pub fn csv_print(media: MediaRoot, table_columns: &Vec<String>) {
let mut wtr = csv::Writer::from_writer(std::io::stdout());

for media_item in media.items {
wtr.write_record(
build_table_row(&media_item, table_columns)
).unwrap();
}
}

pub fn json_print(media: MediaRoot) {
println!("{}", serde_json::to_string_pretty(&media).unwrap());
}
}

fn build_table_row(media_item: &MediaItem, table_columns: &Vec<String>) -> Vec<String> {
let mut row = Vec::new();

for column in table_columns {
match column.to_uppercase().as_str() {
"NAME" => row.push(media_item.name.to_string()),
"ID" => row.push(media_item.id.to_string()),
"TYPE" => row.push(media_item.type_field.to_string()),
"PATH" => row.push(media_item.path.to_string()),
"CRITICRATING" => row.push(media_item.critic_rating.to_string()),
"PRODUCTIONYEAR" => row.push(media_item.production_year.to_string()),
_ => row.push("?".to_string())
}
}

row
}

4 changes: 3 additions & 1 deletion src/entities/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ pub mod plugin_details;
pub mod activity_details;
pub mod server_info;
pub mod token_details;
pub mod media_details;
pub mod media_details;
pub mod repository_details;
pub mod package_details;
54 changes: 54 additions & 0 deletions src/entities/package_details.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use comfy_table::{ Table, ContentArrangement };
pub type PackageDetailsRoot = Vec<PackageDetails>;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PackageDetails {
pub name: String,
pub description: String,
pub overview: String,
pub owner: String,
pub category: String,
pub guid: String,
pub versions: Vec<Version>,
#[serde(default)]
pub image_url: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Version {
pub version: String,
#[serde(rename = "VersionNumber")]
pub version_number: String,
pub changelog: String,
pub target_abi: String,
pub source_url: String,
pub checksum: String,
pub timestamp: String,
pub repository_name: String,
pub repository_url: String,
}

impl PackageDetails {
pub fn json_print(packages: &[PackageDetails]) {
println!("{}", serde_json::to_string_pretty(&packages).unwrap());
}

pub fn table_print(packages: Vec<PackageDetails>) {
let mut table = Table::new();
table
.set_content_arrangement(ContentArrangement::Dynamic)
.set_width(120)
.set_header(vec!["Name", "Description", "Overview", "Owner", "GUID", "Category", "Versions"]);
for package in packages {
let mut version_output: String = "".to_string();
for version in package.versions {
version_output.push_str(version.version.as_str());
version_output.push(' ');
}
table.add_row(vec![package.name, package.description, package.overview, package.owner, package.guid, package.category, version_output]);
}
println!("{table}");
}
}
41 changes: 41 additions & 0 deletions src/entities/repository_details.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use comfy_table::{ Table, ContentArrangement };

pub type RepositoryDetailsRoot = Vec<RepositoryDetails>;

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RepositoryDetails {
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "Url")]
pub url: String,
#[serde(rename = "Enabled")]
pub enabled: bool,
}

impl RepositoryDetails {
pub fn new (name: String, url: String, enabled: bool) -> RepositoryDetails {
RepositoryDetails {
name,
url,
enabled
}
}

pub fn json_print(repos: &[RepositoryDetails]) {
println!("{}", serde_json::to_string_pretty(&repos).unwrap());
}

pub fn table_print(repos: Vec<RepositoryDetails>) {
let mut table = Table::new();
table
.set_content_arrangement(ContentArrangement::Dynamic)
.set_width(120)
.set_header(vec!["Plugin Name", "Version", "Config Filename", "Description", "Id", "Can Uninstall", "Image", "Status"]);
for repo in repos {
table.add_row(vec![repo.name, repo.url, repo.enabled.to_string()]);

}
println!("{table}");
}
}
Loading

0 comments on commit a0385be

Please sign in to comment.