-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from SamTV12345/114-custom-folderfile-naming
114 custom folderfile naming
- Loading branch information
Showing
32 changed files
with
676 additions
and
113 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
migrations/2023-05-14-184857_podcast-name-adjustment/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-- This file should undo anything in `up.sql` | ||
ALTER TABLE settings DROP COLUMN replace_invalid_characters; | ||
ALTER TABLE settings DROP COLUMN use_existing_filename; | ||
ALTER TABLE settings DROP COLUMN replacement_strategy; | ||
ALTER TABLE settings DROP COLUMN episode_format; | ||
ALTER TABLE settings DROP COLUMN podcast_format; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- Your SQL goes here | ||
ALTER TABLE settings ADD COLUMN replace_invalid_characters BOOLEAN DEFAULT TRUE NOT NULL; | ||
ALTER TABLE settings ADD COLUMN use_existing_filename BOOLEAN DEFAULT FALSE NOT NULL; | ||
ALTER TABLE settings ADD COLUMN replacement_strategy TEXT CHECK(replacement_strategy IN | ||
('replace-with-dash-and-underscore', 'remove', 'replace-with-dash')) NOT NULL DEFAULT | ||
'replace-with-dash-and-underscore'; | ||
ALTER TABLE settings ADD COLUMN episode_format TEXT NOT NULL DEFAULT '{}'; | ||
ALTER TABLE settings ADD COLUMN podcast_format TEXT NOT NULL DEFAULT '{}'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
|
||
|
||
|
||
use crate::models::itunes_models::{Podcast, PodcastEpisode}; | ||
use crate::service::file_service::{prepare_podcast_episode_title_to_directory}; | ||
use crate::service::path_service::PathService; | ||
|
||
#[derive(Default, Clone, Debug)] | ||
pub struct FilenameBuilder { | ||
episode: String, | ||
raw_episode: PodcastEpisode, | ||
directory: String, | ||
suffix: String, | ||
image_suffix: String, | ||
image_filename: String, | ||
filename: String, | ||
raw_filename: bool, | ||
podcast: Podcast | ||
} | ||
|
||
impl FilenameBuilder { | ||
|
||
pub fn with_podcast_directory(mut self, directory: &str) -> FilenameBuilder { | ||
self.directory = directory.to_string(); | ||
self | ||
} | ||
|
||
pub fn with_episode(mut self, podcast_episode: PodcastEpisode) -> FilenameBuilder { | ||
self.episode = prepare_podcast_episode_title_to_directory(podcast_episode.clone()); | ||
self.raw_episode = podcast_episode; | ||
self | ||
} | ||
|
||
pub fn with_filename(mut self, filename: &str) -> FilenameBuilder { | ||
self.filename = filename.to_string(); | ||
self | ||
} | ||
|
||
pub fn with_image_filename(mut self, image_filename: &str) -> FilenameBuilder { | ||
self.image_filename = image_filename.to_string(); | ||
self | ||
} | ||
|
||
pub fn with_suffix(mut self, suffix: &str) -> FilenameBuilder { | ||
self.suffix = suffix.to_string(); | ||
self | ||
} | ||
|
||
pub fn with_image_suffix(mut self, image_suffix: &str) -> FilenameBuilder { | ||
self.image_suffix = image_suffix.to_string(); | ||
self | ||
} | ||
|
||
pub fn with_raw_directory(mut self) -> FilenameBuilder { | ||
self.directory = PathService::get_image_path( | ||
&self.podcast.clone().directory_name, | ||
Some(self.raw_episode.clone()), | ||
&self.suffix, | ||
&self.raw_episode.name | ||
); | ||
self.raw_filename = true; | ||
self | ||
} | ||
|
||
pub fn with_podcast(mut self, podcast: Podcast) -> FilenameBuilder { | ||
self.podcast = podcast; | ||
self | ||
} | ||
|
||
pub fn build(self)->(String, String){ | ||
if self.raw_filename{ | ||
let resulting_directory = self.clone().create_podcast_episode_dir(self.directory.clone | ||
()); | ||
return (format!("{}/{}.{}", resulting_directory,self.filename.clone(), self.suffix | ||
.clone()),format!("{}/{}.{}", resulting_directory,self.image_filename.clone(), self.image_suffix | ||
.clone())); | ||
} | ||
let resulting_directory = self.clone().create_podcast_episode_dir(format!("{}/{}",self | ||
.directory.clone(), self.episode.clone())); | ||
|
||
return (format!("{}/{}.{}", resulting_directory,self.filename.clone(), self.suffix.clone | ||
()),format!("{}/{}.{}", resulting_directory,self.image_filename.clone(), self.image_suffix | ||
.clone())); | ||
} | ||
|
||
|
||
fn create_podcast_episode_dir(self,dirname:String)->String{ | ||
PathService::check_if_podcast_episode_directory_available | ||
(&dirname, self.podcast) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ pub mod episode; | |
pub mod podcast_rssadd_model; | ||
pub mod order_criteria; | ||
pub mod filter; | ||
pub mod file_path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.