Skip to content

Commit

Permalink
start of watcglist
Browse files Browse the repository at this point in the history
  • Loading branch information
lostb1t committed Jul 11, 2024
1 parent cbe5b73 commit 9df6520
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod transform;
pub mod logging;
pub mod cache;
pub mod routes;
pub mod webhooks;
//pub mod proxy;
pub mod timeout;
pub mod headers;
Expand Down
10 changes: 8 additions & 2 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::timeout::*;
use crate::transform::*;
use crate::url::*;
use crate::utils::*;
use crate::webhooks;
use itertools::Itertools;
use moka::notification::RemovalCause;
use moka::sync::Cache as MokaCacheSync;
Expand Down Expand Up @@ -168,7 +169,7 @@ pub fn route() -> Router {
)
.push(
Router::new()
.path("/webhooks/plex")
.path("/replex/webhooks")
.post(webhook_plex),
)
.push(
Expand Down Expand Up @@ -369,8 +370,13 @@ pub async fn webhook_plex(
req: &mut Request,
res: &mut Response,
) -> Result<(), anyhow::Error> {
let payload = req.form::<String>("payload").await;
dbg!("YOOO");
let raw = req.form::<String>("payload").await;
let payload: webhooks::Payload = serde_json::from_str(&raw.unwrap())?;
dbg!(&req);
dbg!(payload);

// watchlist();
res.render(());
return Ok(());
}
Expand Down
181 changes: 181 additions & 0 deletions src/schema.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
schema {
query: Query
# mutation: Mutation
}

# type Mutation
# type Query {
# popularTitles(
# country: String
# after: String
# offset: Boolean
# after: String
# # filter: $popularTitlesFilter
# sortBy: String # actuall an enum?
# ): # sortRandomSeed: $sortRandomSeed
# PopularTitlesConnection!
# }

# type PopularTitlesConnection {
# "A list of edges."
# edges: [PopularTitlesEdge]

# "A list of nodes."
# nodes: [UserContentEdit]

# "Information to aid in pagination."
# pageInfo: PageInfo!

# "Identifies the total count of items in the connection."
# totalCount: Int!
# }

type PageInfo {
startCursor: String
endCursor: String
hasPreviousPage: Boolean
hasNextPage: Boolean
# __typename: String
}

type User {
id: String
username: String
}

# type WatchNowOffer {
# id: String
# standardWebURL: String
# retailPrice: String
# retailPriceValue: Float
# lastChangeRetailPriceValue: String
# currency: String
# presentationType: String
# monetizationType: String
# availableTo: String
# # __typename: String
# package: Package
# }

# type Offers {
# id: String
# standardWebURL: String
# deeplinkURL(platform: Platform): String
# retailPrice: String
# retailPriceValue: Float
# lastChangeRetailPriceValue: Float
# currency: String
# presentationType: String
# monetizationType: String
# availableTo: String
# # __typename: String
# package: Package
# }

# type Genres {
# translation: String
# # __typename: String
# }

# type Credits {
# name: String
# personId: Int
# # __typename: String
# }

# type Scoring {
# imdbVotes: Int
# imdbScore: Float
# tmdbPopularity: Float
# tmdbScore: Float
# # __typename: String
# }

# type Content {
# title: String
# fullPath: String
# posterUrl: String
# # __typename: String
# isReleased: Boolean
# runtime: Int
# genres: [Genres]
# credits: [Credits]
# backdrops: [String]
# dailymotionClips: [String]
# scoring: Scoring
# externalIds: externalIds
# }

# type Node {
# id: String
# objectId: Int
# objectType: String
# likelistEntry: String
# dislikelistEntry: String
# watchlistEntry: String
# seenlistEntry: String
# # __typename: String
# # watchNowOffer: WatchNowOffer
# # offers: [Offers]
# offers(country: String, platform: Platform!): [Offers]
# content(country: String, language: Language!): Content!
# }

# type externalIds {
# tmdbId: String
# imdbId: String
# }

# interface PopularTitlesEdge {
# cursor: String
# # __typename: String
# node: Node
# }

# type PopularTitles {
# # sponsoredAd: String
# totalCount: Int
# # __typename: String
# pageInfo: PageInfo
# edges: [PopularTitlesEdge]
# }

# type Query {
# popularTitles(
# country: Country!
# sortBy: PopularTitlesSorting!
# # language: Language
# after: String!
# first: Int!
# offset: Int
# # filter: $popularTitlesFilter
# ): PopularTitles!
# }

# enum PopularTitlesSorting {
# ALPHABETICAL
# POPULAR
# }

# enum Country {
# NL
# BE
# }

# enum Language {
# nl
# be
# en
# }

# enum Platform {
# IOS
# TVOS
# ANDROID
# WEB
# }


# type AutogeneratedMainType {
# data: Data
# }
78 changes: 78 additions & 0 deletions src/webhooks.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// use serde_derive::Deserialize;
// use serde_derive::Serialize;
use serde::{Deserialize, Deserializer, Serialize};

pub fn watchlist(payload: Payload) {

}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Payload {
pub event: String,
pub user: bool,
pub owner: bool,
#[serde(rename = "Account")]
pub account: Account,
#[serde(rename = "Server")]
pub server: Server,
#[serde(rename = "Player")]
pub player: Player,
#[serde(rename = "Metadata")]
pub metadata: Metadata,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Account {
pub id: i64,
pub thumb: String,
pub title: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Server {
pub title: String,
pub uuid: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Player {
pub local: bool,
pub public_address: String,
pub title: String,
pub uuid: String,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Metadata {
pub library_section_type: String,
pub rating_key: String,
pub key: String,
pub parent_rating_key: String,
pub grandparent_rating_key: String,
pub guid: String,
#[serde(rename = "librarySectionID")]
pub library_section_id: i64,
#[serde(rename = "type")]
pub type_field: String,
pub title: String,
pub grandparent_key: String,
pub parent_key: String,
pub grandparent_title: Option<String>,
pub parent_title: Option<String>,
pub summary: String,
pub index: i64,
pub parent_index: i64,
pub rating_count: i64,
pub thumb: String,
pub art: String,
pub parent_thumb: String,
pub grandparent_thumb: String,
pub grandparent_art: String,
pub added_at: i64,
pub updated_at: i64,
}

0 comments on commit 9df6520

Please sign in to comment.