Added watched field into the Episodes table.

This commit is contained in:
Jordan Petridis 2017-10-28 04:58:35 +03:00
parent e6ceb86201
commit 86c686bba6
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
4 changed files with 5 additions and 3 deletions

View File

@ -20,6 +20,7 @@ CREATE TABLE `episode` (
`epoch` INTEGER NOT NULL DEFAULT 0, `epoch` INTEGER NOT NULL DEFAULT 0,
`length` INTEGER, `length` INTEGER,
`guid` TEXT, `guid` TEXT,
`watched` INTEGER ,
`podcast_id` INTEGER NOT NULL `podcast_id` INTEGER NOT NULL
); );

View File

@ -6,6 +6,7 @@ use models;
// TODO: look into how bad-utf8 is handled in rss crate, // TODO: look into how bad-utf8 is handled in rss crate,
// and figure if there is a need for checking before parsing. // and figure if there is a need for checking before parsing.
// TODO: Extend the support for parsing itunes extensions // TODO: Extend the support for parsing itunes extensions
/// Parses a rss::Channel into a NewPodcast Struct.
pub fn parse_podcast(chan: &Channel, source_id: i32) -> models::NewPodcast { pub fn parse_podcast(chan: &Channel, source_id: i32) -> models::NewPodcast {
let title = chan.title().trim().to_owned(); let title = chan.title().trim().to_owned();
let link = chan.link().trim().to_owned(); let link = chan.link().trim().to_owned();
@ -29,11 +30,11 @@ pub fn parse_podcast(chan: &Channel, source_id: i32) -> models::NewPodcast {
} }
} }
/// Parses a rss::Item into a NewEpisode Struct.
pub fn parse_episode(item: &Item, parent_id: i32) -> models::NewEpisode { pub fn parse_episode(item: &Item, parent_id: i32) -> models::NewEpisode {
let title = item.title().map(|s| s.trim()); let title = item.title().map(|s| s.trim());
let description = item.description().map(|s| s.trim()); let description = item.description().map(|s| s.trim());
let guid = item.guid().map(|x| x.value().trim()); let guid = item.guid().map(|x| x.value().trim());
let local_uri = None;
// Its kinda weird this being an Option type. // Its kinda weird this being an Option type.
// Rss 2.0 specified that it's optional. // Rss 2.0 specified that it's optional.
@ -63,7 +64,6 @@ pub fn parse_episode(item: &Item, parent_id: i32) -> models::NewEpisode {
models::NewEpisode { models::NewEpisode {
title, title,
uri, uri,
local_uri,
description, description,
length, length,
published_date: pub_date, published_date: pub_date,

View File

@ -20,6 +20,7 @@ pub struct Episode {
epoch: i32, epoch: i32,
length: Option<i32>, length: Option<i32>,
guid: Option<String>, guid: Option<String>,
watched: Option<i32>,
podcast_id: i32, podcast_id: i32,
} }
@ -245,7 +246,6 @@ impl<'a> NewSource<'a> {
pub struct NewEpisode<'a> { pub struct NewEpisode<'a> {
pub title: Option<&'a str>, pub title: Option<&'a str>,
pub uri: Option<&'a str>, pub uri: Option<&'a str>,
pub local_uri: Option<&'a str>,
pub description: Option<&'a str>, pub description: Option<&'a str>,
pub published_date: Option<String>, pub published_date: Option<String>,
pub length: Option<i32>, pub length: Option<i32>,

View File

@ -9,6 +9,7 @@ table! {
epoch -> Integer, epoch -> Integer,
length -> Nullable<Integer>, length -> Nullable<Integer>,
guid -> Nullable<Text>, guid -> Nullable<Text>,
watched -> Nullable<Integer>,
podcast_id -> Integer, podcast_id -> Integer,
} }
} }