diff --git a/src/db/insert.rs b/src/db/insert.rs index 6735c34..db8aa01 100644 --- a/src/db/insert.rs +++ b/src/db/insert.rs @@ -47,7 +47,7 @@ pub fn create_playlist(new_playlist: UserPlaylist) -> Result<(), DatabaseErrors> // although it would seem intelligent to include the length of the song, there is nowhere where that data can really live, and make sense // like when we select from the table, should length be included? sounds sort of stupid. so we just query it here... /// order num is the current length of the playlist. so if there is 3 songs, order_num should be three -pub fn add_to_playlist_bulk( +pub fn _add_to_playlist_bulk( playlist_uuid: &str, uniqueid: Vec, order_num: usize, diff --git a/src/db/update.rs b/src/db/update.rs index fc96a97..82077c5 100644 --- a/src/db/update.rs +++ b/src/db/update.rs @@ -1,4 +1,3 @@ -use super::insert::add_to_playlist; use crate::types::{DatabaseErrors, UserPlaylist}; use log::info; use rusqlite::{params, Connection}; diff --git a/src/gui/messages.rs b/src/gui/messages.rs index f4b722c..723a2ce 100644 --- a/src/gui/messages.rs +++ b/src/gui/messages.rs @@ -3,7 +3,6 @@ use crate::types::{AppError, PungeMusicObject, UserPlaylist}; use crate::types::{MusicData, YouTubeData}; -use rodio::Sink; use serde::{ser, Deserialize, Serialize}; use tokio::sync::mpsc as async_sender; #[derive(Debug, Clone, Serialize, Deserialize)] diff --git a/src/gui/persistent.rs b/src/gui/persistent.rs index f5b57ee..e9b471e 100644 --- a/src/gui/persistent.rs +++ b/src/gui/persistent.rs @@ -266,9 +266,6 @@ impl App { .spacing(5), ) .height(iced::Length::Fill) - // .style(iced::theme::Container::Custom(Box::new( - // ContainerWithBorder, - // ))) .into() } } diff --git a/src/gui/song_edit_page.rs b/src/gui/song_edit_page.rs index 4f38f67..0782236 100644 --- a/src/gui/song_edit_page.rs +++ b/src/gui/song_edit_page.rs @@ -50,7 +50,6 @@ impl SongEditPage { author: self.author.clone(), album: self.album.clone(), uniqueid: self.uniqueid.clone(), - row_num: 0, // doesn't matter. we're using this type for convinence sake... } )) .style(|t, status| punge_button_style(status)), diff --git a/src/gui/start.rs b/src/gui/start.rs index 5b72699..5d9c88c 100644 --- a/src/gui/start.rs +++ b/src/gui/start.rs @@ -1,8 +1,8 @@ use crate::db::fetch::{get_all_from_playlist, get_all_main, get_all_playlists, get_obj_from_uuid}; use crate::db::insert::create_playlist; use crate::db::update::{ - delete_from_playlist, delete_playlist, move_song_down_one, move_song_up_one, - quick_swap_title_author, update_auth_album, update_song, + delete_from_playlist, move_song_down_one, move_song_up_one, quick_swap_title_author, + update_auth_album, update_song, }; use crate::gui::messages::{ AppEvent, CheckBoxType, ComboBoxType, Context, Page, ProgramCommands, PungeCommand, TextType, @@ -167,12 +167,10 @@ impl Default for App { table_content: get_all_main() .unwrap() .into_iter() - .enumerate() - .map(|(count, item)| crate::gui::widgets::row::RowData { + .map(|item| crate::gui::widgets::row::RowData { title: item.title.clone(), author: item.author.clone(), album: item.album.clone(), - row_num: count, uniqueid: item.uniqueid.clone(), }) .collect(), @@ -986,15 +984,6 @@ impl App { Command::none() } - ProgramCommands::DeletePlaylist(id) => { - // you cannot delete main. - if id.to_lowercase() != "main" { - delete_playlist(&id).unwrap(); - // refresh the playlist... - self.user_playlists = get_all_playlists().unwrap(); - } - Command::none() - } ProgramCommands::UpdatePlaylist => { crate::db::update::update_playlist( &self.playlist_page.user_title, @@ -1208,13 +1197,11 @@ impl App { let new = get_all_main().unwrap(); self.table_content = new .into_iter() - .enumerate() - .map(|(count, item)| crate::gui::widgets::row::RowData { + .map(|item| crate::gui::widgets::row::RowData { title: item.title, author: item.author, album: item.album, uniqueid: item.uniqueid, - row_num: count, }) .collect(); } else { @@ -1222,13 +1209,11 @@ impl App { debug!("viewing_playlist: {:?}", &self.viewing_playlist); self.table_content = new .into_iter() - .enumerate() - .map(|(count, item)| crate::gui::widgets::row::RowData { + .map(|item| crate::gui::widgets::row::RowData { title: item.title, author: item.author, album: item.album, uniqueid: item.uniqueid, - row_num: count, }) .collect(); } diff --git a/src/gui/style/button.rs b/src/gui/style/button.rs index 780f0bb..35ce2fd 100644 --- a/src/gui/style/button.rs +++ b/src/gui/style/button.rs @@ -129,8 +129,8 @@ pub fn menu_button_style(status: Status) -> Style { _ => Style::default(), } } - -pub fn sub_menu_button_style(status: Status) -> Style { +// might come back and use this style.. +pub fn _sub_menu_button_style(status: Status) -> Style { match status { Status::Active => Style { background: None, @@ -332,7 +332,5 @@ pub fn punge_button_style(status: Status) -> Style { }, shadow: Shadow::default(), }, - - _ => Style::default(), } } diff --git a/src/gui/style/container.rs b/src/gui/style/container.rs index fefe8bb..f2fd56d 100644 --- a/src/gui/style/container.rs +++ b/src/gui/style/container.rs @@ -2,9 +2,8 @@ use iced::border::Radius; use iced::widget::container::Style; use iced::{Background, Border, Color, Shadow, Vector}; -pub struct ContainerWithBorder; - -pub fn container_with_border() -> Style { +// most was for debugging the container size lol +pub fn _container_with_border() -> Style { Style { text_color: None, background: None, diff --git a/src/gui/subscription.rs b/src/gui/subscription.rs index 34d26a2..bd25ff4 100644 --- a/src/gui/subscription.rs +++ b/src/gui/subscription.rs @@ -118,7 +118,6 @@ impl App { album: music_obj.current_object.album.clone(), thumbnail: music_obj.current_object.savelocationjpg.clone(), song_id: music_obj.current_object.uniqueid.clone(), - previous_id: None, // doesnt matter unless we are on skip_forward volume: music_obj.sink.volume(), is_playing: false, shuffle: music_obj.shuffle, @@ -151,7 +150,6 @@ impl App { album: music_obj.current_object.album.clone(), thumbnail: music_obj.current_object.savelocationjpg.clone(), song_id: music_obj.current_object.uniqueid.clone(), - previous_id: None, // i dont think we can know this here? volume: music_obj.sink.volume(), is_playing: true, shuffle: music_obj.shuffle, @@ -166,7 +164,6 @@ impl App { PungeCommand::SkipForwards => { // so i guess the answer is doing .stop()? not .clear(). ig cause .stop() also clears the queue music_obj.sink.stop(); - let old_id = music_obj.current_object.uniqueid.clone(); music_obj.count = change_count(true, music_obj.count, music_obj.list.len()); music_obj.current_object = music_obj.list[music_obj.count].clone(); @@ -183,7 +180,6 @@ impl App { album: music_obj.current_object.album.clone(), thumbnail: music_obj.current_object.savelocationjpg.clone(), song_id: music_obj.current_object.uniqueid.clone(), - previous_id: Some(old_id), volume: music_obj.sink.volume(), is_playing: true, shuffle: music_obj.shuffle, @@ -212,7 +208,6 @@ impl App { album: music_obj.current_object.album.clone(), thumbnail: music_obj.current_object.savelocationjpg.clone(), song_id: music_obj.current_object.uniqueid.clone(), - previous_id: None, volume: music_obj.sink.volume(), is_playing: true, shuffle: music_obj.shuffle, @@ -249,7 +244,6 @@ impl App { album: music_obj.current_object.album.clone(), thumbnail: music_obj.current_object.savelocationjpg.clone(), song_id: music_obj.current_object.uniqueid.clone(), - previous_id: None, volume: music_obj.sink.volume(), is_playing: true, shuffle: music_obj.shuffle, @@ -287,7 +281,6 @@ impl App { album: music_obj.current_object.album.clone(), thumbnail: music_obj.current_object.savelocationjpg.clone(), song_id: music_obj.current_object.uniqueid.clone(), - previous_id: None, volume: music_obj.sink.volume(), is_playing: false, shuffle: music_obj.shuffle, @@ -395,7 +388,6 @@ impl App { .current_object .uniqueid .clone(), - previous_id: None, // not known. volume: music_obj.sink.volume(), is_playing: false, // we can only pause... shuffle: music_obj.shuffle, @@ -439,7 +431,6 @@ impl App { .current_object .uniqueid .clone(), - previous_id: Some(old_id), volume: music_obj.sink.volume(), is_playing: true, shuffle: music_obj.shuffle, @@ -486,7 +477,6 @@ impl App { .current_object .uniqueid .clone(), - previous_id: None, volume: music_obj.sink.volume(), is_playing: true, shuffle: music_obj.shuffle, @@ -530,7 +520,6 @@ impl App { .current_object .uniqueid .clone(), - previous_id: None, volume: music_obj.sink.volume(), is_playing: true, shuffle: music_obj.shuffle, @@ -645,7 +634,6 @@ impl App { .current_object .uniqueid .clone(), - previous_id: None, volume: music_obj.sink.volume(), is_playing: true, shuffle: music_obj.shuffle, @@ -696,7 +684,6 @@ impl App { album: music_obj.current_object.album.clone(), thumbnail: music_obj.current_object.savelocationjpg.clone(), song_id: music_obj.current_object.uniqueid.clone(), - previous_id: None, volume: music_obj.sink.volume(), is_playing: true, shuffle: music_obj.shuffle, diff --git a/src/gui/widgets/hover_menu.rs b/src/gui/widgets/hover_menu.rs index 44ce626..4bf5089 100644 --- a/src/gui/widgets/hover_menu.rs +++ b/src/gui/widgets/hover_menu.rs @@ -1,12 +1,10 @@ use crate::gui::style::button::punge_button_style; -use crate::gui::widgets::row::{RowState, RowWidget}; +use crate::gui::widgets::row::RowState; use iced::advanced::layout::Limits; -use iced::advanced::text::Editor; -use iced::advanced::{layout, renderer, widget::Tree, widget::Widget, Overlay}; -use iced::advanced::{mouse, overlay}; -use iced::event::Status; -use iced::widget::{button, column, row, text, Button, Row}; -use iced::{Border, Color, Element, Event, Length, Point, Shadow, Size, Theme, Vector}; +use iced::advanced::mouse; +use iced::advanced::{layout, renderer, widget::Tree, Overlay}; +use iced::widget::{button, column, text}; +use iced::{Element, Event, Size}; pub fn create_hover_menu<'a, Message, Theme, Renderer>( add_to_msg: fn(String, String) -> Message, diff --git a/src/gui/widgets/playlist_button.rs b/src/gui/widgets/playlist_button.rs index 5db6485..1af6d22 100644 --- a/src/gui/widgets/playlist_button.rs +++ b/src/gui/widgets/playlist_button.rs @@ -3,7 +3,6 @@ use iced::advanced::layout::Limits; // and a right-click will show some playlist options (edit, move up, move down, duplicate, play) use iced::advanced::{layout, renderer, widget::Tree, widget::Widget}; use iced::advanced::{mouse, Overlay}; -use iced::widget::{button}; use iced::Event; use iced::{Element, Length, Point, Size, Vector}; @@ -176,7 +175,7 @@ where } iced::event::Status::Ignored } - Event::Mouse(mouse::Event::CursorMoved { position }) => { + Event::Mouse(mouse::Event::CursorMoved { position: _ }) => { if st.show_menu { let tmp = cursor.position(); match tmp { @@ -228,7 +227,7 @@ where pub struct PlaylistButtonOverlay<'a, Message, Theme, Renderer> where Message: 'a + Clone, - Theme: button::Catalog, + Theme: iced::widget::button::Catalog, Renderer: iced::advanced::Renderer + iced::advanced::text::Renderer, { pub tree: &'a mut Tree, @@ -240,7 +239,7 @@ impl<'a, Message, Theme, Renderer> Overlay for PlaylistButtonOverlay<'a, Message, Theme, Renderer> where Message: Clone, - Theme: button::Catalog + iced::widget::text::Catalog, + Theme: iced::widget::button::Catalog + iced::widget::text::Catalog, Renderer: iced::advanced::Renderer + iced::advanced::text::Renderer, { fn layout(&mut self, renderer: &Renderer, bounds: Size) -> layout::Node { @@ -296,7 +295,7 @@ impl<'a, Message, Theme, Renderer> From where Message: 'a + Clone, - Theme: 'a + button::Catalog + iced::widget::text::Catalog, + Theme: 'a + iced::widget::button::Catalog + iced::widget::text::Catalog, Renderer: 'a + iced::advanced::Renderer + iced::advanced::text::Renderer, { fn from(overlay: PlaylistButtonOverlay<'a, Message, Theme, Renderer>) -> Self { diff --git a/src/gui/widgets/row.rs b/src/gui/widgets/row.rs index c55d0c0..b360c0f 100644 --- a/src/gui/widgets/row.rs +++ b/src/gui/widgets/row.rs @@ -1,41 +1,18 @@ -use crate::gui::widgets::hover_menu::create_hover_menu; use crate::gui::widgets::row_overlay::OverlayButtons; use iced::advanced::mouse; use iced::advanced::{layout, renderer, widget::Tree, widget::Widget}; -use iced::widget::{button, column, row, text, Column, Row}; +use iced::widget::{button, row, text}; use iced::Event; -use iced::{Border, Color, Element, Length, Point, Shadow, Size, Theme, Vector}; +use iced::{Border, Color, Element, Length, Point, Size, Vector}; use crate::gui::style::button::punge_button_style; // i dont think this is the best way to make this work. but passing in the Element from main.rs just caused issues // like if it is held by the main struct, we cannot pass it into the overlay!? -pub fn create_menu<'a, 'b, Message, Theme, Renderer>( - delete_msg: Message, - quick_swap_msg: Message, - add_to_msg: fn(String, String) -> Message, - uuid_list: Vec<(String, String)>, -) -> Element<'a, Message, Theme, Renderer> -where - Message: 'a + Clone, - Theme: 'a + button::Catalog + iced::widget::text::Catalog, - Renderer: 'a + iced::advanced::Renderer + iced::advanced::text::Renderer, - 'b: 'a, -{ - column![ - button(text("delete")).on_press(delete_msg), - button(text("Edit")), - button(text("Quickswap 1")).on_press(quick_swap_msg), - button(text("Add to...")) - ] - .into() -} - #[derive(Debug, Clone)] pub struct RowData { pub title: String, pub author: String, pub album: String, - pub row_num: usize, pub uniqueid: String, } diff --git a/src/gui/widgets/row_overlay.rs b/src/gui/widgets/row_overlay.rs index 6570ba2..9da9631 100644 --- a/src/gui/widgets/row_overlay.rs +++ b/src/gui/widgets/row_overlay.rs @@ -1,10 +1,9 @@ -use crate::gui::widgets::row::{create_menu, RowState, RowWidget}; +use crate::gui::widgets::row::RowState; use iced::advanced::layout::Limits; -use iced::advanced::{layout, renderer, widget::Tree, widget::Widget, Overlay}; +use iced::advanced::{layout, renderer, widget::Tree, Overlay}; use iced::advanced::{mouse, overlay}; -use iced::event::Status; -use iced::widget::{button, column, row, text, Button, Row}; -use iced::{Border, Color, Element, Event, Length, Padding, Point, Shadow, Size, Theme, Vector}; +use iced::widget::button; +use iced::{Element, Event, Point, Size}; pub struct OverlayButtons<'a, Message, Theme, Renderer> where diff --git a/src/types.rs b/src/types.rs index 5fa4869..707275a 100644 --- a/src/types.rs +++ b/src/types.rs @@ -122,6 +122,7 @@ pub enum DatabaseErrors { } #[derive(Debug, Clone)] +#[allow(dead_code)] // nice to have for errors... pub enum AppError { DatabaseError(DatabaseErrors), YoutubeError(String), // url, what went wrong @@ -171,7 +172,6 @@ pub struct MusicData { pub album: String, pub thumbnail: String, // path to the thumbnail pub song_id: String, - pub previous_id: Option, // used only inside of skip_forward database subscription, None otherwise. pub volume: f32, pub is_playing: bool, pub shuffle: bool, @@ -189,7 +189,6 @@ impl MusicData { album: "".to_string(), thumbnail: "".to_string(), song_id: "".to_string(), - previous_id: None, volume: 0.0, is_playing: false, shuffle: false, @@ -232,7 +231,6 @@ pub struct YouTubeData { pub title: String, pub author: String, pub album: String, - pub url: String, } #[derive(Debug, Clone)] diff --git a/src/utils/db.rs b/src/utils/db.rs deleted file mode 100644 index 8e79e94..0000000 --- a/src/utils/db.rs +++ /dev/null @@ -1,98 +0,0 @@ -// this is pretty much only for me (or other punge enthusiasts), adds the 'order' to the database rows -// since we are actually going to do #20 now... -pub fn add_count_to_all_main() { - let conn = rusqlite::Connection::open("main.db").unwrap(); - let mut fixed: Vec = Vec::new(); - let mut stmt = conn - .prepare( - "SELECT title, author, album, features, length, savelocationmp3, savelocationjpg, - datedownloaded, lastlistenedto, ischild, uniqueid, plays, weight, threshold FROM main", - ) - .unwrap(); - let the_iter = stmt - .query_map(rusqlite::params![], |row| { - Ok(OldPungeMusicObject { - title: row.get(0)?, - author: row.get(1)?, - album: row.get(2)?, - features: row.get(3)?, - length: row.get(4)?, - savelocationmp3: row.get(5)?, - savelocationjpg: row.get(6)?, - datedownloaded: row.get(7)?, - lastlistenedto: row.get(8)?, - ischild: row.get(9)?, - uniqueid: row.get(10)?, - plays: row.get(11)?, - weight: row.get(12)?, - threshold: row.get(13)?, - }) - }) - .unwrap(); - for (count, obj) in the_iter.enumerate() { - let o = obj.unwrap(); - let new_item = crate::types::PungeMusicObject { - title: o.title, - author: o.author, - album: o.album, - features: o.features, - length: o.length, - savelocationmp3: o.savelocationmp3, - savelocationjpg: o.savelocationjpg, - datedownloaded: o.datedownloaded, - lastlistenedto: o.lastlistenedto, - ischild: o.ischild, - uniqueid: o.uniqueid, - plays: o.plays, - weight: o.weight, - threshold: o.threshold, - order: count, - }; - fixed.push(new_item); - } - conn.execute("DROP TABLE main", rusqlite::params![]) - .unwrap(); - conn.execute( - "CREATE TABLE main ( - title TEXT, - author TEXT, - album TEXT, - features TEXT, - length SMALLINT, - savelocationmp3 TEXT, - savelocationjpg TEXT, - datedownloaded DATE, - lastlistenedto DATE, - ischild BOOL, - uniqueid TEXT PRIMARY KEY, - plays SMALLINT, - weight SMALLINT, - threshold SMALLINT, - user_order INT - )", - rusqlite::params![], - ) - .unwrap(); - for music_obj in fixed { - crate::db::insert::add_to_main(music_obj).unwrap(); - } -} -use chrono::NaiveDate; - -#[derive(Clone)] -pub struct OldPungeMusicObject { - pub title: String, - pub author: String, - pub album: String, - pub features: String, - pub length: u32, // in seconds - pub savelocationmp3: String, - pub savelocationjpg: String, - pub datedownloaded: NaiveDate, - pub lastlistenedto: NaiveDate, - pub ischild: bool, // used in reconstruction of lost music that exists in DB - pub uniqueid: String, - pub plays: u16, - pub weight: i16, - pub threshold: u16, -} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 33b97c4..48720fc 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,9 +1,7 @@ pub mod backup; pub mod cache; -pub mod db; pub mod delete; pub mod image; pub mod key; -pub mod playlist; pub mod sep_video; pub mod time; diff --git a/src/utils/playlist.rs b/src/utils/playlist.rs deleted file mode 100644 index 0a8e6e4..0000000 --- a/src/utils/playlist.rs +++ /dev/null @@ -1,149 +0,0 @@ -use crate::types::Playlist; -use log::{info, warn}; -use regex::Regex; -use serde_json::Value; -use std::collections::HashMap; - -// this is a file used to get the links of each song in a playlist. -// inspired to have the same functionality as pytube -// (https://github.com/pytube/pytube) (./pytube/contrib/playlist.py) - -// It should also be known that this does *not* support downloading playlists with more than 100 videos - -use crate::types::AppError; - -pub async fn get_playlist(link: String) -> Result { - info!("fetching html"); - let html: String = get_html(&link); - info!("parsing for json"); - let json: String = parse_for_js(html); - info!("getting video metadata"); - let extras: (String, String, u64) = get_extras(&json); - info!("converting to list of videos"); - let video_vec: Vec = json_to_vec_videos(&json); - let final_exp: Playlist = Playlist { - links: video_vec, - title: extras.0, - author: extras.1, - length: extras.2, - }; - Ok(final_exp) -} -// gets the html from the given link -fn get_html(link: &str) -> String { - reqwest::blocking::get(link).unwrap().text().unwrap() -} -// function to get the extra information from the json -fn get_extras(json: &str) -> (String, String, u64) { - let obj: Value = serde_json::from_str(json).unwrap(); - let title: String = - obj["contents"]["twoColumnWatchNextResults"]["playlist"]["playlist"]["title"].to_string(); - let author: String = obj["contents"]["twoColumnWatchNextResults"]["playlist"]["playlist"] - ["ownerName"]["simpleText"] - .to_string(); - let count: u64 = obj["contents"]["twoColumnWatchNextResults"]["playlist"]["playlist"] - ["totalVideos"] - .as_u64() - .unwrap(); - (title, author, count) -} - -// turns the json into a vec of the videos -fn json_to_vec_videos(to_json: &str) -> Vec { - // new vector that will contain the links - let mut return_vals: Vec = Vec::new(); - // turn the json(string) into json(serde_json::Value) - let obj: Value = serde_json::from_str(to_json).expect("The json was invalid"); - // this is an array of the playlist contents - let vals = &obj["contents"]["twoColumnWatchNextResults"]["playlist"]["playlist"]["contents"]; - let bruh = vals.as_array().unwrap(); - for video in bruh { - let id = &video["playlistPanelVideoRenderer"]["videoId"].as_str(); - match id { - Some(t) => { - let string = format!["https://youtube.com/watch?v={}", t]; - return_vals.push(string) - } - None => { - warn!("Unable to fetch video data. Ignoring.") - } - } - } - return_vals -} - -// parses the html looking for the json object -fn parse_for_js(html: String) -> String { - // regex pattern to find the "ytInitialData = " string that signifies the json obj - let pattern = r#"ytInitialData\s*=\s*"#; - // unwrap the pattern - let re = Regex::new(pattern).unwrap(); - // finds the only instance of this, if not found in the html, a panic occurs - let result = re.find(&html).expect("Pattern not found!"); - // get the end of the found pattern. This will give the char position in the html where - // the obj begins - let start_index = result.end(); - // now we call the function that will loop over that html (form that start_index) and get the obj - find_object_from_startpoint(&html, start_index) -} - -// main loop that will find the exactly bounds of the json -fn find_object_from_startpoint(old_html: &str, starting: usize) -> String { - // defines the new html as from the starting point (beginning of json) - let html = &old_html[starting..]; - // defines html as a vector of chars, easier to operate with - let html: Vec = html.chars().collect(); - // starting index. Skipping 0 because first letter must be an open brace, so it is placed in stack - let mut i: usize = 1; - // making sure that first char is either a [ or { (seems to always be a '{' ) - if html[0] != '{' && html[0] != '[' { - // panics if it isnt either - panic!("Invalid start point!") - } - // first char, will be added to the stack - let first_temp: char = html[0]; - // create the stack (adding the first char in there) - let mut stack: Vec = vec![first_temp]; - // context closes used during iteration - let context_closers: HashMap = - HashMap::from([('{', '}'), ('[', ']'), ('\"', '\"')]); - while i < html.len() { - // if that stack length == 0 that means we have reached the end of the object because - // there are no more context closers (aka keeping tack of how many braces there are) - if stack.is_empty() { - break; - } - // updates the current char - let curr_char: char = html[i]; - // curr_context = the last item in the stack - let curr_context = stack[stack.len() - 1]; - // first if statement is a guard against a panic! (if curr_char == context_closers[curr_context] - if context_closers.contains_key(&curr_context) { - // so if it is contained in it, and curr_char == it, pop one off the stack - if curr_char == context_closers[&curr_context] { - stack.pop().unwrap(); - i += 1; - continue; - }; - } - - // "Strings require special context handling because they can contain context openers *and* closers" - if curr_context == '\"' { - if curr_char == '\\' { - i += 2; - continue; - } - } else { - // "Non-string contexts are when we need to look for context openers." - if context_closers.contains_key(&curr_char) { - stack.push(curr_char) - } - } - // add one after each iteration :) - i += 1 - } - // define the json, and return it as a string ! - let full_obj: &[char] = &html[..i]; - let _ret_obj: String = full_obj.iter().collect(); - return full_obj.iter().collect(); -} diff --git a/src/yt/interface.rs b/src/yt/interface.rs index 73d05b0..50bd4c6 100644 --- a/src/yt/interface.rs +++ b/src/yt/interface.rs @@ -61,7 +61,6 @@ pub async fn download_interface( title, author, album, - url: url.clone(), }; let obj = create_punge_obj( video, @@ -87,7 +86,6 @@ pub async fn download_interface( title, author: author.unwrap().name.to_string(), album, - url: url.clone(), }; let obj = create_punge_obj( video, @@ -118,7 +116,6 @@ pub async fn download_interface( title: String::from("no title here :)"), author: auth, album, - url: url.clone(), }; let temp_punge_obj = create_punge_obj( video.clone(), @@ -153,7 +150,6 @@ pub async fn download_interface( title, author: author.unwrap().name, album, - url: url.clone(), }; let obj = create_punge_obj( video, @@ -175,7 +171,6 @@ pub async fn download_interface( title: details.title, author: details.author.unwrap().name, album: String::from("Single"), - url: url.clone(), }; let obj = create_punge_obj( video,