diff --git a/hammond-data/src/dbqueries.rs b/hammond-data/src/dbqueries.rs index 9ee4d55..1e83f46 100644 --- a/hammond-data/src/dbqueries.rs +++ b/hammond-data/src/dbqueries.rs @@ -23,18 +23,18 @@ pub fn get_sources() -> Result, DataError> { .map_err(From::from) } -pub fn get_podcasts() -> Result, DataError> { +pub fn get_podcasts() -> Result, DataError> { use schema::shows::dsl::*; let db = connection(); let con = db.get()?; shows .order(title.asc()) - .load::(&con) + .load::(&con) .map_err(From::from) } -pub fn get_podcasts_filter(filter_ids: &[i32]) -> Result, DataError> { +pub fn get_podcasts_filter(filter_ids: &[i32]) -> Result, DataError> { use schema::shows::dsl::*; let db = connection(); let con = db.get()?; @@ -42,7 +42,7 @@ pub fn get_podcasts_filter(filter_ids: &[i32]) -> Result, DataError shows .order(title.asc()) .filter(id.ne_all(filter_ids)) - .load::(&con) + .load::(&con) .map_err(From::from) } @@ -149,18 +149,18 @@ pub fn get_episodes_widgets_filter_limit( .map_err(From::from) } -pub fn get_podcast_from_id(pid: i32) -> Result { +pub fn get_podcast_from_id(pid: i32) -> Result { use schema::shows::dsl::*; let db = connection(); let con = db.get()?; shows .filter(id.eq(pid)) - .get_result::(&con) + .get_result::(&con) .map_err(From::from) } -pub fn get_podcast_cover_from_id(pid: i32) -> Result { +pub fn get_podcast_cover_from_id(pid: i32) -> Result { use schema::shows::dsl::*; let db = connection(); let con = db.get()?; @@ -168,11 +168,11 @@ pub fn get_podcast_cover_from_id(pid: i32) -> Result(&con) + .get_result::(&con) .map_err(From::from) } -pub fn get_pd_episodes(parent: &Podcast) -> Result, DataError> { +pub fn get_pd_episodes(parent: &Show) -> Result, DataError> { use schema::episodes::dsl::*; let db = connection(); let con = db.get()?; @@ -183,7 +183,7 @@ pub fn get_pd_episodes(parent: &Podcast) -> Result, DataError> { .map_err(From::from) } -pub fn get_pd_episodes_count(parent: &Podcast) -> Result { +pub fn get_pd_episodes_count(parent: &Show) -> Result { let db = connection(); let con = db.get()?; @@ -193,7 +193,7 @@ pub fn get_pd_episodes_count(parent: &Podcast) -> Result { .map_err(From::from) } -pub fn get_pd_episodeswidgets(parent: &Podcast) -> Result, DataError> { +pub fn get_pd_episodeswidgets(parent: &Show) -> Result, DataError> { use schema::episodes::dsl::*; let db = connection(); let con = db.get()?; @@ -209,7 +209,7 @@ pub fn get_pd_episodeswidgets(parent: &Podcast) -> Result Result, DataError> { +pub fn get_pd_unplayed_episodes(parent: &Show) -> Result, DataError> { use schema::episodes::dsl::*; let db = connection(); let con = db.get()?; @@ -221,7 +221,7 @@ pub fn get_pd_unplayed_episodes(parent: &Podcast) -> Result, DataEr .map_err(From::from) } -// pub(crate) fn get_pd_episodes_limit(parent: &Podcast, limit: u32) -> +// pub(crate) fn get_pd_episodes_limit(parent: &Show, limit: u32) -> // Result, DataError> { use schema::episodes::dsl::*; // let db = connection(); @@ -256,14 +256,14 @@ pub fn get_source_from_id(id_: i32) -> Result { .map_err(From::from) } -pub fn get_podcast_from_source_id(sid: i32) -> Result { +pub fn get_podcast_from_source_id(sid: i32) -> Result { use schema::shows::dsl::*; let db = connection(); let con = db.get()?; shows .filter(source_id.eq(sid)) - .get_result::(&con) + .get_result::(&con) .map_err(From::from) } @@ -295,7 +295,7 @@ pub(crate) fn get_episode_minimal_from_pk( .map_err(From::from) } -pub(crate) fn remove_feed(pd: &Podcast) -> Result<(), DataError> { +pub(crate) fn remove_feed(pd: &Show) -> Result<(), DataError> { let db = connection(); let con = db.get()?; @@ -400,7 +400,7 @@ pub(crate) fn index_new_episodes(eps: &[NewEpisode]) -> Result<(), DataError> { .map(|_| ()) } -pub fn update_none_to_played_now(parent: &Podcast) -> Result { +pub fn update_none_to_played_now(parent: &Show) -> Result { use schema::episodes::dsl::*; let db = connection(); let con = db.get()?; diff --git a/hammond-data/src/feed.rs b/hammond-data/src/feed.rs index fb49b89..2abcc29 100644 --- a/hammond-data/src/feed.rs +++ b/hammond-data/src/feed.rs @@ -9,7 +9,7 @@ use rss; use dbqueries; use errors::DataError; use models::{Index, IndexState, Update}; -use models::{NewEpisode, NewEpisodeMinimal, NewPodcast, Podcast}; +use models::{NewEpisode, NewEpisodeMinimal, NewShow, Show}; /// Wrapper struct that hold a `Source` id and the `rss::Channel` /// that corresponds to the `Source.uri` field. @@ -31,15 +31,15 @@ impl Feed { .and_then(move |pd| self.index_channel_items(pd)) } - fn parse_podcast(&self) -> NewPodcast { - NewPodcast::new(&self.channel, self.source_id) + fn parse_podcast(&self) -> NewShow { + NewShow::new(&self.channel, self.source_id) } - fn parse_podcast_async(&self) -> impl Future + Send { + fn parse_podcast_async(&self) -> impl Future + Send { ok(self.parse_podcast()) } - fn index_channel_items(self, pd: Podcast) -> impl Future + Send { + fn index_channel_items(self, pd: Show) -> impl Future + Send { let stream = stream::iter_ok::<_, DataError>(self.channel.into_items()); // Parse the episodes @@ -204,7 +204,7 @@ mod tests { let file = fs::File::open(path).unwrap(); let channel = Channel::read_from(BufReader::new(file)).unwrap(); - let pd = NewPodcast::new(&channel, 42); + let pd = NewShow::new(&channel, 42); assert_eq!(feed.parse_podcast(), pd); } diff --git a/hammond-data/src/lib.rs b/hammond-data/src/lib.rs index d1a617c..3444567 100644 --- a/hammond-data/src/lib.rs +++ b/hammond-data/src/lib.rs @@ -81,7 +81,7 @@ pub mod utils; pub use feed::{Feed, FeedBuilder}; pub use models::Save; -pub use models::{Episode, EpisodeWidgetQuery, Podcast, PodcastCoverQuery, Source}; +pub use models::{Episode, EpisodeWidgetQuery, Show, ShowCoverQuery, Source}; // Set the user agent, See #53 for more // Keep this in sync with Tor-browser releases diff --git a/hammond-data/src/models/episode.rs b/hammond-data/src/models/episode.rs index d2a69fc..f5a354b 100644 --- a/hammond-data/src/models/episode.rs +++ b/hammond-data/src/models/episode.rs @@ -5,14 +5,14 @@ use diesel::SaveChangesDsl; use database::connection; use errors::DataError; -use models::{Podcast, Save}; +use models::{Save, Show}; use schema::episodes; #[derive(Queryable, Identifiable, AsChangeset, Associations, PartialEq)] #[table_name = "episodes"] #[changeset_options(treat_none_as_null = "true")] #[primary_key(title, show_id)] -#[belongs_to(Podcast, foreign_key = "show_id")] +#[belongs_to(Show, foreign_key = "show_id")] #[derive(Debug, Clone)] /// Diesel Model of the episode table. pub struct Episode { @@ -152,7 +152,7 @@ impl Episode { self.played = value; } - /// `Podcast` table foreign key. + /// `Show` table foreign key. pub fn show_id(&self) -> i32 { self.show_id } @@ -292,7 +292,7 @@ impl EpisodeWidgetQuery { self.played = value; } - /// `Podcast` table foreign key. + /// `Show` table foreign key. pub fn show_id(&self) -> i32 { self.show_id } @@ -445,7 +445,7 @@ impl EpisodeMinimal { self.duration } - /// `Podcast` table foreign key. + /// `Show` table foreign key. pub fn show_id(&self) -> i32 { self.show_id } diff --git a/hammond-data/src/models/mod.rs b/hammond-data/src/models/mod.rs index 59fffb5..852c2a4 100644 --- a/hammond-data/src/models/mod.rs +++ b/hammond-data/src/models/mod.rs @@ -1,9 +1,9 @@ mod new_episode; -mod new_podcast; +mod new_show; mod new_source; mod episode; -mod podcast; +mod show; mod source; // use futures::prelude::*; @@ -11,16 +11,16 @@ mod source; pub(crate) use self::episode::EpisodeCleanerQuery; pub(crate) use self::new_episode::{NewEpisode, NewEpisodeMinimal}; -pub(crate) use self::new_podcast::NewPodcast; +pub(crate) use self::new_show::NewShow; pub(crate) use self::new_source::NewSource; #[cfg(test)] pub(crate) use self::new_episode::NewEpisodeBuilder; #[cfg(test)] -pub(crate) use self::new_podcast::NewPodcastBuilder; +pub(crate) use self::new_show::NewShowBuilder; pub use self::episode::{Episode, EpisodeMinimal, EpisodeWidgetQuery}; -pub use self::podcast::{Podcast, PodcastCoverQuery}; +pub use self::show::{Show, ShowCoverQuery}; pub use self::source::Source; #[derive(Debug, Clone, PartialEq)] diff --git a/hammond-data/src/models/new_podcast.rs b/hammond-data/src/models/new_show.rs similarity index 89% rename from hammond-data/src/models/new_podcast.rs rename to hammond-data/src/models/new_show.rs index 097ea0b..fd916a0 100644 --- a/hammond-data/src/models/new_podcast.rs +++ b/hammond-data/src/models/new_show.rs @@ -4,7 +4,7 @@ use diesel::prelude::*; use rss; use errors::DataError; -use models::Podcast; +use models::Show; use models::{Index, Insert, Update}; use schema::shows; @@ -18,7 +18,7 @@ use utils::url_cleaner; #[builder(default)] #[builder(derive(Debug))] #[builder(setter(into))] -pub(crate) struct NewPodcast { +pub(crate) struct NewShow { title: String, link: String, description: String, @@ -26,7 +26,7 @@ pub(crate) struct NewPodcast { source_id: i32, } -impl Insert<()> for NewPodcast { +impl Insert<()> for NewShow { type Error = DataError; fn insert(&self) -> Result<(), Self::Error> { @@ -42,7 +42,7 @@ impl Insert<()> for NewPodcast { } } -impl Update<()> for NewPodcast { +impl Update<()> for NewShow { type Error = DataError; fn update(&self, show_id: i32) -> Result<(), Self::Error> { @@ -61,7 +61,7 @@ impl Update<()> for NewPodcast { // TODO: Maybe return an Enum Instead. // It would make unti testing better too. -impl Index<()> for NewPodcast { +impl Index<()> for NewShow { type Error = DataError; fn index(&self) -> Result<(), DataError> { @@ -81,8 +81,8 @@ impl Index<()> for NewPodcast { } } -impl PartialEq for NewPodcast { - fn eq(&self, other: &Podcast) -> bool { +impl PartialEq for NewShow { + fn eq(&self, other: &Show) -> bool { (self.link() == other.link()) && (self.title() == other.title()) && (self.image_uri() == other.image_uri()) @@ -91,9 +91,9 @@ impl PartialEq for NewPodcast { } } -impl NewPodcast { - /// Parses a `rss::Channel` into a `NewPodcast` Struct. - pub(crate) fn new(chan: &rss::Channel, source_id: i32) -> NewPodcast { +impl NewShow { + /// Parses a `rss::Channel` into a `NewShow` Struct. + pub(crate) fn new(chan: &rss::Channel, source_id: i32) -> NewShow { let title = chan.title().trim(); let link = url_cleaner(chan.link().trim()); @@ -111,7 +111,7 @@ impl NewPodcast { // If itunes is None, try to get the channel.image from the rss spec let image_uri = itunes_img.or_else(|| chan.image().map(|s| s.url().trim().to_owned())); - NewPodcastBuilder::default() + NewShowBuilder::default() .title(title) .description(description) .link(link) @@ -122,14 +122,14 @@ impl NewPodcast { } // Look out for when tryinto lands into stable. - pub(crate) fn to_podcast(&self) -> Result { + pub(crate) fn to_podcast(&self) -> Result { self.index()?; dbqueries::get_podcast_from_source_id(self.source_id).map_err(From::from) } } // Ignore the following geters. They are used in unit tests mainly. -impl NewPodcast { +impl NewShow { #[allow(dead_code)] pub(crate) fn source_id(&self) -> i32 { self.source_id @@ -160,14 +160,14 @@ mod tests { use rss::Channel; use database::truncate_db; - use models::NewPodcastBuilder; + use models::NewShowBuilder; use std::fs::File; use std::io::BufReader; - // Pre-built expected NewPodcast structs. + // Pre-built expected NewShow structs. lazy_static! { - static ref EXPECTED_INTERCEPTED: NewPodcast = { + static ref EXPECTED_INTERCEPTED: NewShow = { let descr = "The people behind The Intercept’s fearless reporting and incisive \ commentary—Jeremy Scahill, Glenn Greenwald, Betsy Reed and \ others—discuss the crucial issues of our time: national security, civil \ @@ -175,7 +175,7 @@ mod tests { artists, thinkers, and newsmakers who challenge our preconceptions about \ the world we live in."; - NewPodcastBuilder::default() + NewShowBuilder::default() .title("Intercepted with Jeremy Scahill") .link("https://theintercept.com/podcasts") .description(descr) @@ -188,12 +188,12 @@ mod tests { .build() .unwrap() }; - static ref EXPECTED_LUP: NewPodcast = { + static ref EXPECTED_LUP: NewShow = { let descr = "An open show powered by community LINUX Unplugged takes the best \ attributes of open collaboration and focuses them into a weekly \ lifestyle show about Linux."; - NewPodcastBuilder::default() + NewShowBuilder::default() .title("LINUX Unplugged Podcast") .link("http://www.jupiterbroadcasting.com/") .description(descr) @@ -204,7 +204,7 @@ mod tests { .build() .unwrap() }; - static ref EXPECTED_TIPOFF: NewPodcast = { + static ref EXPECTED_TIPOFF: NewShow = { let desc = "

Welcome to The Tip Off- the podcast where we take you behind the \ scenes of some of the best investigative journalism from recent years. \ Each episode we’ll be digging into an investigative scoop- hearing from \ @@ -215,7 +215,7 @@ mod tests { complicated detective work that goes into doing great investigative \ journalism- then this is the podcast for you.

"; - NewPodcastBuilder::default() + NewShowBuilder::default() .title("The Tip Off") .link("http://www.acast.com/thetipoff") .description(desc) @@ -227,7 +227,7 @@ mod tests { .build() .unwrap() }; - static ref EXPECTED_STARS: NewPodcast = { + static ref EXPECTED_STARS: NewShow = { let descr = "

The first audio drama from Tor Labs and Gideon Media, Steal the Stars \ is a gripping noir science fiction thriller in 14 episodes: Forbidden \ love, a crashed UFO, an alien body, and an impossible heist unlike any \ @@ -237,7 +237,7 @@ mod tests { b183-7311d2e436c3/b3a4aa57a576bb662191f2a6bc2a436c8c4ae256ecffaff5c4c54fd42e\ 923914941c264d01efb1833234b52c9530e67d28a8cebbe3d11a4bc0fbbdf13ecdf1c3.jpeg"; - NewPodcastBuilder::default() + NewShowBuilder::default() .title("Steal the Stars") .link("http://tor-labs.com/") .description(descr) @@ -246,12 +246,12 @@ mod tests { .build() .unwrap() }; - static ref EXPECTED_CODE: NewPodcast = { + static ref EXPECTED_CODE: NewShow = { let descr = "A podcast about humans and technology. Panelists: Coraline Ada Ehmke, \ David Brady, Jessica Kerr, Jay Bobo, Astrid Countee and Sam \ Livingston-Gray. Brought to you by @therubyrep."; - NewPodcastBuilder::default() + NewShowBuilder::default() .title("Greater Than Code") .link("https://www.greaterthancode.com/") .description(descr) @@ -262,8 +262,8 @@ mod tests { .build() .unwrap() }; - static ref EXPECTED_ELLINOFRENEIA: NewPodcast = { - NewPodcastBuilder::default() + static ref EXPECTED_ELLINOFRENEIA: NewShow = { + NewShowBuilder::default() .title("Ελληνοφρένεια") .link("https://ellinofreneia.sealabs.net/feed.rss") .description("Ανεπίσημο feed της Ελληνοφρένειας") @@ -272,8 +272,8 @@ mod tests { .build() .unwrap() }; - static ref UPDATED_DESC_INTERCEPTED: NewPodcast = { - NewPodcastBuilder::default() + static ref UPDATED_DESC_INTERCEPTED: NewShow = { + NewShowBuilder::default() .title("Intercepted with Jeremy Scahill") .link("https://theintercept.com/podcasts") .description("New Description") @@ -293,7 +293,7 @@ mod tests { let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap(); let channel = Channel::read_from(BufReader::new(file)).unwrap(); - let pd = NewPodcast::new(&channel, 42); + let pd = NewShow::new(&channel, 42); assert_eq!(*EXPECTED_INTERCEPTED, pd); } @@ -302,7 +302,7 @@ mod tests { let file = File::open("tests/feeds/2018-01-20-LinuxUnplugged.xml").unwrap(); let channel = Channel::read_from(BufReader::new(file)).unwrap(); - let pd = NewPodcast::new(&channel, 42); + let pd = NewShow::new(&channel, 42); assert_eq!(*EXPECTED_LUP, pd); } @@ -311,7 +311,7 @@ mod tests { let file = File::open("tests/feeds/2018-01-20-TheTipOff.xml").unwrap(); let channel = Channel::read_from(BufReader::new(file)).unwrap(); - let pd = NewPodcast::new(&channel, 42); + let pd = NewShow::new(&channel, 42); assert_eq!(*EXPECTED_TIPOFF, pd); } @@ -320,7 +320,7 @@ mod tests { let file = File::open("tests/feeds/2018-01-20-StealTheStars.xml").unwrap(); let channel = Channel::read_from(BufReader::new(file)).unwrap(); - let pd = NewPodcast::new(&channel, 42); + let pd = NewShow::new(&channel, 42); assert_eq!(*EXPECTED_STARS, pd); } @@ -329,7 +329,7 @@ mod tests { let file = File::open("tests/feeds/2018-01-20-GreaterThanCode.xml").unwrap(); let channel = Channel::read_from(BufReader::new(file)).unwrap(); - let pd = NewPodcast::new(&channel, 42); + let pd = NewShow::new(&channel, 42); assert_eq!(*EXPECTED_CODE, pd); } @@ -338,7 +338,7 @@ mod tests { let file = File::open("tests/feeds/2018-03-28-Ellinofreneia.xml").unwrap(); let channel = Channel::read_from(BufReader::new(file)).unwrap(); - let pd = NewPodcast::new(&channel, 42); + let pd = NewShow::new(&channel, 42); assert_eq!(*EXPECTED_ELLINOFRENEIA, pd); } @@ -349,7 +349,7 @@ mod tests { let file = File::open("tests/feeds/2018-01-20-Intercepted.xml").unwrap(); let channel = Channel::read_from(BufReader::new(file)).unwrap(); - let npd = NewPodcast::new(&channel, 42); + let npd = NewShow::new(&channel, 42); npd.insert().unwrap(); let pd = dbqueries::get_podcast_from_source_id(42).unwrap(); @@ -388,14 +388,14 @@ mod tests { assert!(EXPECTED_INTERCEPTED.index().is_ok()); // Get the podcast let old = dbqueries::get_podcast_from_source_id(42).unwrap(); - // Assert that NewPodcast is equal to the Indexed one + // Assert that NewShow is equal to the Indexed one assert_eq!(&*EXPECTED_INTERCEPTED, &old); let updated = &*UPDATED_DESC_INTERCEPTED; // Update the podcast assert!(updated.index().is_ok()); - // Get the new Podcast + // Get the new Show let new = dbqueries::get_podcast_from_source_id(42).unwrap(); // Assert it's diff from the old one. assert_ne!(new, old); diff --git a/hammond-data/src/models/podcast.rs b/hammond-data/src/models/show.rs similarity index 82% rename from hammond-data/src/models/podcast.rs rename to hammond-data/src/models/show.rs index 9d1fa55..d9a3b0a 100644 --- a/hammond-data/src/models/podcast.rs +++ b/hammond-data/src/models/show.rs @@ -11,7 +11,7 @@ use schema::shows; #[table_name = "shows"] #[derive(Debug, Clone)] /// Diesel Model of the shows table. -pub struct Podcast { +pub struct Show { id: i32, title: String, link: String, @@ -20,20 +20,20 @@ pub struct Podcast { source_id: i32, } -impl Save for Podcast { +impl Save for Show { type Error = DataError; /// Helper method to easily save/"sync" current state of self to the /// Database. - fn save(&self) -> Result { + fn save(&self) -> Result { let db = connection(); let tempdb = db.get()?; - self.save_changes::(&*tempdb).map_err(From::from) + self.save_changes::(&*tempdb).map_err(From::from) } } -impl Podcast { +impl Show { /// Get the Feed `id`. pub fn id(&self) -> i32 { self.id @@ -51,7 +51,7 @@ impl Podcast { &self.link } - /// Set the Podcast/Feed `link`. + /// Set the Show/Feed `link`. pub fn set_link(&mut self, value: &str) { self.link = value.to_string(); } @@ -85,17 +85,17 @@ impl Podcast { } #[derive(Queryable, Debug, Clone)] -/// Diesel Model of the podcast cover query. -/// Used for fetching information about a Podcast's cover. -pub struct PodcastCoverQuery { +/// Diesel Model of the Show cover query. +/// Used for fetching information about a Show's cover. +pub struct ShowCoverQuery { id: i32, title: String, image_uri: Option, } -impl From for PodcastCoverQuery { - fn from(p: Podcast) -> PodcastCoverQuery { - PodcastCoverQuery { +impl From for ShowCoverQuery { + fn from(p: Show) -> ShowCoverQuery { + ShowCoverQuery { id: p.id(), title: p.title, image_uri: p.image_uri, @@ -103,7 +103,7 @@ impl From for PodcastCoverQuery { } } -impl PodcastCoverQuery { +impl ShowCoverQuery { /// Get the Feed `id`. pub fn id(&self) -> i32 { self.id diff --git a/hammond-data/src/utils.rs b/hammond-data/src/utils.rs index f123a57..bc7021e 100644 --- a/hammond-data/src/utils.rs +++ b/hammond-data/src/utils.rs @@ -7,7 +7,7 @@ use url::{Position, Url}; use dbqueries; use errors::DataError; -use models::{EpisodeCleanerQuery, Podcast, Save}; +use models::{EpisodeCleanerQuery, Save, Show}; use xdg_dirs::DL_DIR; use std::fs; @@ -108,9 +108,9 @@ pub fn url_cleaner(s: &str) -> String { } } -/// Returns the URI of a Podcast Downloads given it's title. +/// Returns the URI of a Show Downloads given it's title. pub fn get_download_folder(pd_title: &str) -> Result { - // It might be better to make it a hash of the title or the podcast rowid + // It might be better to make it a hash of the title or the Show rowid let download_fold = format!("{}/{}", DL_DIR.to_str().unwrap(), pd_title); // Create the folder @@ -123,7 +123,7 @@ pub fn get_download_folder(pd_title: &str) -> Result { /// Removes all the entries associated with the given show from the database, /// and deletes all of the downloaded content. // TODO: Write Tests -pub fn delete_show(pd: &Podcast) -> Result<(), DataError> { +pub fn delete_show(pd: &Show) -> Result<(), DataError> { dbqueries::remove_feed(pd)?; info!("{} was removed succesfully.", pd.title()); diff --git a/hammond-downloader/src/downloader.rs b/hammond-downloader/src/downloader.rs index 28fe2ca..1f5e63b 100644 --- a/hammond-downloader/src/downloader.rs +++ b/hammond-downloader/src/downloader.rs @@ -12,7 +12,7 @@ use std::path::Path; use std::sync::{Arc, Mutex}; use hammond_data::xdg_dirs::HAMMOND_CACHE; -use hammond_data::{EpisodeWidgetQuery, PodcastCoverQuery, Save}; +use hammond_data::{EpisodeWidgetQuery, Save, ShowCoverQuery}; // use failure::Error; use errors::DownloadError; @@ -196,7 +196,7 @@ pub fn get_episode( Ok(()) } -pub fn cache_image(pd: &PodcastCoverQuery) -> Result { +pub fn cache_image(pd: &ShowCoverQuery) -> Result { let url = pd .image_uri() .ok_or_else(|| DownloadError::NoImageLocation)? diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index 18bba1b..6cc56d6 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -10,7 +10,7 @@ use gtk::prelude::*; use gtk::SettingsExt as GtkSettingsExt; use crossbeam_channel::{unbounded, Receiver, Sender}; -use hammond_data::Podcast; +use hammond_data::Show; use headerbar::Header; use settings::{self, WindowGeometry}; @@ -43,7 +43,7 @@ pub enum Action { RefreshEpisodesView, RefreshEpisodesViewBGR, RefreshShowsView, - ReplaceWidget(Arc), + ReplaceWidget(Arc), RefreshWidgetIfSame(i32), ShowWidgetAnimated, ShowShowsAnimated, @@ -51,8 +51,8 @@ pub enum Action { HeaderBarNormal, HeaderBarShowUpdateIndicator, HeaderBarHideUpdateIndicator, - MarkAllPlayerNotification(Arc), - RemoveShow(Arc), + MarkAllPlayerNotification(Arc), + RemoveShow(Arc), ErrorNotification(String), InitEpisode(i32), } diff --git a/hammond-gtk/src/stacks/populated.rs b/hammond-gtk/src/stacks/populated.rs index 3ccdf89..d192b4f 100644 --- a/hammond-gtk/src/stacks/populated.rs +++ b/hammond-gtk/src/stacks/populated.rs @@ -6,7 +6,7 @@ use crossbeam_channel::Sender; use failure::Error; use hammond_data::dbqueries; -use hammond_data::Podcast; +use hammond_data::Show; use app::Action; use widgets::{ShowWidget, ShowsView}; @@ -89,7 +89,7 @@ impl PopulatedStack { Ok(()) } - pub fn replace_widget(&mut self, pd: Arc) -> Result<(), Error> { + pub fn replace_widget(&mut self, pd: Arc) -> Result<(), Error> { let old = self.show.container.clone(); // save the ShowWidget vertical scrollabar alignment diff --git a/hammond-gtk/src/widgets/player.rs b/hammond-gtk/src/widgets/player.rs index 179e3a9..2a47d6e 100644 --- a/hammond-gtk/src/widgets/player.rs +++ b/hammond-gtk/src/widgets/player.rs @@ -14,7 +14,7 @@ use failure::Error; use send_cell::SendCell; use hammond_data::{dbqueries, USER_AGENT}; -use hammond_data::{EpisodeWidgetQuery, PodcastCoverQuery}; +use hammond_data::{EpisodeWidgetQuery, ShowCoverQuery}; use app::Action; use utils::set_image_from_path; @@ -49,7 +49,7 @@ struct PlayerInfo { impl PlayerInfo { // FIXME: create a Diesel Model of the joined episode and podcast query instead - fn init(&self, episode: &EpisodeWidgetQuery, podcast: &PodcastCoverQuery) { + fn init(&self, episode: &EpisodeWidgetQuery, podcast: &ShowCoverQuery) { self.set_cover_image(podcast); self.set_show_title(podcast); self.set_episode_title(episode); @@ -60,12 +60,12 @@ impl PlayerInfo { self.episode.set_tooltip_text(episode.title()); } - fn set_show_title(&self, show: &PodcastCoverQuery) { + fn set_show_title(&self, show: &ShowCoverQuery) { self.show.set_text(show.title()); self.show.set_tooltip_text(show.title()); } - fn set_cover_image(&self, show: &PodcastCoverQuery) { + fn set_cover_image(&self, show: &ShowCoverQuery) { set_image_from_path(&self.cover, show.id(), 34) .map_err(|err| error!("Player Cover: {}", err)) .ok(); diff --git a/hammond-gtk/src/widgets/show.rs b/hammond-gtk/src/widgets/show.rs index 84b6b23..e62249e 100644 --- a/hammond-gtk/src/widgets/show.rs +++ b/hammond-gtk/src/widgets/show.rs @@ -11,7 +11,7 @@ use send_cell::SendCell; use hammond_data::dbqueries; use hammond_data::utils::delete_show; -use hammond_data::Podcast; +use hammond_data::Show; use app::Action; use utils::{self, lazy_load}; @@ -67,7 +67,7 @@ impl Default for ShowWidget { } impl ShowWidget { - pub fn new(pd: Arc, sender: Sender) -> Rc { + pub fn new(pd: Arc, sender: Sender) -> Rc { let mut pdw = ShowWidget::default(); pdw.init(&pd, &sender); let pdw = Rc::new(pdw); @@ -78,7 +78,7 @@ impl ShowWidget { pdw } - pub fn init(&mut self, pd: &Arc, sender: &Sender) { + pub fn init(&mut self, pd: &Arc, sender: &Sender) { let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/show_widget.ui"); self.unsub @@ -118,7 +118,7 @@ impl ShowWidget { } /// Set the show cover. - fn set_cover(&self, pd: &Arc) -> Result<(), Error> { + fn set_cover(&self, pd: &Arc) -> Result<(), Error> { utils::set_image_from_path(&self.cover, pd.id(), 256) } @@ -143,7 +143,7 @@ impl ShowWidget { } /// Set scrolled window vertical adjustment. - fn set_vadjustment(&self, pd: &Arc) -> Result<(), Error> { + fn set_vadjustment(&self, pd: &Arc) -> Result<(), Error> { let guard = SHOW_WIDGET_VALIGNMENT .lock() .map_err(|err| format_err!("Failed to lock widget align mutex: {}", err))?; @@ -174,7 +174,7 @@ impl ShowWidget { /// Populate the listbox with the shows episodes. fn populate_listbox( show: &Rc, - pd: Arc, + pd: Arc, sender: Sender, ) -> Result<(), Error> { use crossbeam_channel::bounded; @@ -223,7 +223,7 @@ fn populate_listbox( Ok(()) } -fn on_unsub_button_clicked(pd: Arc, unsub_button: >k::Button, sender: &Sender) { +fn on_unsub_button_clicked(pd: Arc, unsub_button: >k::Button, sender: &Sender) { // hack to get away without properly checking for none. // if pressed twice would panic. unsub_button.set_sensitive(false); @@ -239,7 +239,7 @@ fn on_unsub_button_clicked(pd: Arc, unsub_button: >k::Button, sender: unsub_button.set_sensitive(true); } -fn on_played_button_clicked(pd: Arc, episodes: >k::ListBox, sender: &Sender) { +fn on_played_button_clicked(pd: Arc, episodes: >k::ListBox, sender: &Sender) { if dim_titles(episodes).is_none() { error!("Something went horribly wrong when dimming the titles."); warn!("RUN WHILE YOU STILL CAN!"); @@ -248,7 +248,7 @@ fn on_played_button_clicked(pd: Arc, episodes: >k::ListBox, sender: & sender.send(Action::MarkAllPlayerNotification(pd)) } -fn mark_all_watched(pd: &Podcast, sender: &Sender) -> Result<(), Error> { +fn mark_all_watched(pd: &Show, sender: &Sender) -> Result<(), Error> { dbqueries::update_none_to_played_now(pd)?; // Not all widgets migth have been loaded when the mark_all is hit // So we will need to refresh again after it's done. @@ -257,7 +257,7 @@ fn mark_all_watched(pd: &Podcast, sender: &Sender) -> Result<(), Error> Ok(()) } -pub fn mark_all_notif(pd: Arc, sender: &Sender) -> InAppNotification { +pub fn mark_all_notif(pd: Arc, sender: &Sender) -> InAppNotification { let id = pd.id(); let callback = clone!(sender => move || { mark_all_watched(&pd, &sender) @@ -271,7 +271,7 @@ pub fn mark_all_notif(pd: Arc, sender: &Sender) -> InAppNotific InAppNotification::new(text, callback, undo_callback, UndoState::Shown) } -pub fn remove_show_notif(pd: Arc, sender: Sender) -> InAppNotification { +pub fn remove_show_notif(pd: Arc, sender: Sender) -> InAppNotification { let text = format!("Unsubscribed from {}", pd.title()); utils::ignore_show(pd.id()) diff --git a/hammond-gtk/src/widgets/shows_view.rs b/hammond-gtk/src/widgets/shows_view.rs index 1e7bbf9..5504a73 100644 --- a/hammond-gtk/src/widgets/shows_view.rs +++ b/hammond-gtk/src/widgets/shows_view.rs @@ -6,7 +6,7 @@ use failure::Error; use send_cell::SendCell; use hammond_data::dbqueries; -use hammond_data::Podcast; +use hammond_data::Show; use app::Action; use utils::{self, get_ignored_shows, lazy_load, set_image_from_path}; @@ -45,7 +45,7 @@ impl ShowsView { pub fn new(sender: Sender) -> Result, Error> { let pop = Rc::new(ShowsView::default()); pop.init(sender); - // Populate the flowbox with the Podcasts. + // Populate the flowbox with the Shows. populate_flowbox(&pop)?; Ok(pop) } @@ -147,13 +147,13 @@ impl Default for ShowsChild { } impl ShowsChild { - pub fn new(pd: &Podcast) -> ShowsChild { + pub fn new(pd: &Show) -> ShowsChild { let child = ShowsChild::default(); child.init(pd); child } - fn init(&self, pd: &Podcast) { + fn init(&self, pd: &Show) { self.container.set_tooltip_text(pd.title()); WidgetExt::set_name(&self.child, &pd.id().to_string());