Skip to content

Commit

Permalink
rename to talecast
Browse files Browse the repository at this point in the history
  • Loading branch information
TBS1996 committed Apr 9, 2024
1 parent ff4543a commit 4a7c5a6
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 100 deletions.
61 changes: 34 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cringecast"
version = "0.1.6"
name = "talecast"
version = "0.1.7"
edition = "2021"
description = "Simple CLI podcatcher"
license = "MIT"
Expand Down Expand Up @@ -30,4 +30,5 @@ quick-xml = "0.31.0"
quickxml_to_serde = "0.6.0"
strum = "0.21"
strum_macros = "0.21"
uuid = "1.8.0"

17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# CringeCast
# TaleCast

Simple CLI podcatcher.


https://github.com/TBS1996/CringeCast/assets/56874491/ca3b08e0-b509-44a2-a214-5b7c20a0f609
https://github.com/TBS1996/TaleCast/assets/56874491/ca3b08e0-b509-44a2-a214-5b7c20a0f609

## why?

Expand All @@ -21,15 +21,15 @@ I dislike databases for simple terminal programs. Other programs tend to use a d

## how to install?

you gotta have rust installed atm. You can do `cargo install cringecast` or clone the repo and run it.
you gotta have rust installed atm. You can do `cargo install talecast` or clone the repo and run it.

## how to configure it?

the global config is located in:
`~/.config/cringecast/config.toml`
`~/.config/talecast/config.toml`

you put your podcasts in this file:
~/.config/cringecast/podcasts.toml`
~/.config/talecast/podcasts.toml`

example podcasts.toml:

Expand Down Expand Up @@ -98,10 +98,3 @@ path="/foo/bar/baz"

delete or modify the `.downloaded` file in the folder where the episodes are downloaded.

## why the name?

'broadcast' in norwegian means kringkasting. I thought the "kasting" sounds the 'cast' in 'podcast'. while the 'kring' part sounds like cringe. so, cringecast. pretty dumb i know.




2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod podcast;
mod tags;
mod utils;

pub const APPNAME: &'static str = "cringecast";
pub const APPNAME: &'static str = "talecast";

#[derive(Parser)]
#[command(version, about, long_about = None)]
Expand Down
2 changes: 1 addition & 1 deletion src/opml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub async fn export(p: &Path, config_path: &Path, filter: Option<&regex::Regex>)

let mut opml = OPML {
head: Some(Head {
title: Some("Cringecast Podcast Feeds".to_string()),
title: Some("TaleCast Podcast Feeds".to_string()),
date_created: Some(chrono::Utc::now().to_rfc2822()),
..Head::default()
}),
Expand Down
119 changes: 63 additions & 56 deletions src/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,6 @@ use crate::podcast::Podcast;

use regex::Regex;

#[derive(PartialEq)]
pub enum SourceType {
Episode,
Podcast,
Id3,
}

impl SourceType {
pub fn all() -> Vec<Self> {
vec![Self::Episode, Self::Podcast, Self::Id3]
}
}

#[derive(Default, Clone, Copy)]
pub struct DataSources<'a> {
id3: Option<&'a id3::Tag>,
episode: Option<&'a Episode<'a>>,
podcast: Option<&'a Podcast>,
}

impl<'a> DataSources<'a> {
fn id3(&self) -> &'a id3::Tag {
self.id3.unwrap()
}

fn episode(&self) -> &'a Episode<'a> {
self.episode.unwrap()
}

fn podcast(&self) -> &'a Podcast {
self.podcast.unwrap()
}

pub fn set_episode(mut self, episode: &'a Episode<'a>) -> Self {
self.episode = Some(episode);
self
}

pub fn set_podcast(mut self, podcast: &'a Podcast) -> Self {
self.podcast = Some(podcast);
self
}

pub fn set_id3(mut self, id3: &'a id3::Tag) -> Self {
self.id3 = Some(id3);
self
}
}

#[derive(Debug, Clone)]
pub struct FullPattern(Vec<Segment>);

Expand All @@ -69,11 +20,17 @@ impl FullPattern {
for c in s.chars() {
if c == '}' {
assert!(is_inside);
let pattern = std::mem::take(&mut pattern);
let pattern = Pattern::from_str(&pattern).unwrap();
let text_pattern = std::mem::take(&mut pattern);
let pattern = Pattern::from_str(&text_pattern);
if let Some(required_source) = pattern.required_source() {
if !available_sources.contains(&required_source) {
panic!("invalid tag");
eprintln!("CONFIGURATION ERROR");
eprintln!(
"invalid pattern: {}\n{:?} requires the \"{:?}\"-source which is not available for this configuration setting.",
s, text_pattern, required_source
);

std::process::exit(1);
}
}
let segment = Segment::Pattern(pattern);
Expand Down Expand Up @@ -109,20 +66,70 @@ enum Segment {
Pattern(Pattern),
}

#[derive(PartialEq, Debug)]
pub enum SourceType {
Episode,
Podcast,
Id3,
}

impl SourceType {
pub fn all() -> Vec<Self> {
vec![Self::Episode, Self::Podcast, Self::Id3]
}
}

#[derive(Default, Clone, Copy)]
pub struct DataSources<'a> {
id3: Option<&'a id3::Tag>,
episode: Option<&'a Episode<'a>>,
podcast: Option<&'a Podcast>,
}

impl<'a> DataSources<'a> {
fn id3(&self) -> &'a id3::Tag {
self.id3.unwrap()
}

fn episode(&self) -> &'a Episode<'a> {
self.episode.unwrap()
}

fn podcast(&self) -> &'a Podcast {
self.podcast.unwrap()
}

pub fn set_episode(mut self, episode: &'a Episode<'a>) -> Self {
self.episode = Some(episode);
self
}

pub fn set_podcast(mut self, podcast: &'a Podcast) -> Self {
self.podcast = Some(podcast);
self
}

pub fn set_id3(mut self, id3: &'a id3::Tag) -> Self {
self.id3 = Some(id3);
self
}
}

#[derive(Debug, Clone)]
enum Pattern {
Unit(UnitPattern),
Data(DataPattern),
}

impl Pattern {
fn from_str(s: &str) -> Option<Self> {
fn from_str(s: &str) -> Self {
if let Some(unit) = UnitPattern::from_str(s) {
Some(Self::Unit(unit))
Self::Unit(unit)
} else if let Some(data) = DataPattern::from_str(s) {
Some(Self::Data(data))
Self::Data(data)
} else {
None
eprintln!("invalid pattern: \"{}\"", s);
std::process::exit(1);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn tutorial() -> &'static str {
# Get started
1. find a podcast you like, for example from `https://podcastindex.org`.
2. click 'copy rss'. Then open or create the `podcasts.toml` file in your `~/.config/cringecast/` directory.
2. click 'copy rss'. Then open or create the `podcasts.toml` file in your `~/.config/talecast/` directory.
3. format it as so:
[podcast_name]
Expand Down

0 comments on commit 4a7c5a6

Please sign in to comment.