diff --git a/Cargo.toml b/Cargo.toml index 9e39268..6c751fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,6 +56,8 @@ openssl = { version = "=0.10.40" } http-cache-reqwest = { version = "0.4.5" } reqwest-middleware = { version = "0.1.6" } +itertools = "0.13" + [profile.release] lto = true opt-level = 3 diff --git a/stremio-core-protobuf/Cargo.toml b/stremio-core-protobuf/Cargo.toml index 2857df1..5215c2c 100644 --- a/stremio-core-protobuf/Cargo.toml +++ b/stremio-core-protobuf/Cargo.toml @@ -22,6 +22,7 @@ semver = { version = "1", features = ["serde"] } chrono = "0.4.*" boolinator = "2.4.*" Inflector = "0.11.*" +itertools.workspace = true hex = "0.4.*" url = { version = "2.4", features = ["serde"] } diff --git a/stremio-core-protobuf/src/bridge/loadable.rs b/stremio-core-protobuf/src/bridge/loadable.rs index 19ac4c1..e9ea8f1 100644 --- a/stremio-core-protobuf/src/bridge/loadable.rs +++ b/stremio-core-protobuf/src/bridge/loadable.rs @@ -1,24 +1,29 @@ +use itertools::Itertools; use url::Url; -use stremio_core::deep_links::MetaItemDeepLinks; -use stremio_core::models::common::{Loadable, ResourceError}; -use stremio_core::models::ctx::{Ctx, CtxError}; -use stremio_core::models::link::LinkError; -use stremio_core::models::streaming_server::PlaybackDevice; -use stremio_core::runtime::EnvError; - -use stremio_core::types::{ - addon::{Descriptor, DescriptorPreview, ResourcePath, ResourceRequest}, - api::{GetModalResponse, GetNotificationResponse, LinkAuthKey, LinkCodeResponse}, - library::LibraryItem, - resource::{MetaItem, MetaItemPreview, Stream, Subtitles}, - streaming_server::{Settings, Statistics}, - watched_bitfield::WatchedBitField, +use stremio_core::{ + deep_links::MetaItemDeepLinks, + models::{ + common::{Loadable, ResourceError}, + ctx::{Ctx, CtxError}, + link::LinkError, + streaming_server::PlaybackDevice, + }, + runtime::EnvError, + types::{ + addon::{Descriptor, DescriptorPreview, ResourcePath, ResourceRequest}, + api::{GetModalResponse, GetNotificationResponse, LinkAuthKey, LinkCodeResponse}, + library::LibraryItem, + resource::{MetaItem, MetaItemPreview, Stream, Subtitles}, + streaming_server::{Settings, Statistics}, + watched_bitfield::WatchedBitField, + }, }; -use crate::bridge::ToProtobuf; -use crate::protobuf::stremio::core::models; -use crate::protobuf::stremio::core::models::{LoadedModal, LoadedNotification, PlaybackDevices}; +use crate::{ + bridge::ToProtobuf, + protobuf::stremio::core::models::{self, LoadedModal, LoadedNotification, PlaybackDevices}, +}; impl ToProtobuf for Loadable, ResourceError> @@ -29,7 +34,12 @@ impl ToProtobuf ) -> models::loadable_page::Content { match &self { Loadable::Ready(ready) => models::loadable_page::Content::Ready(models::Page { - meta_items: ready.to_protobuf::(&(*ctx, *request)), + meta_items: ready + .iter() + .unique_by(|meta_item| &meta_item.id) + .map(|meta_item| meta_item.to_owned()) + .collect_vec() + .to_protobuf(&(*ctx, *request)), }), Loadable::Err(error) => models::loadable_page::Content::Error(models::Error { message: error.to_string(),