diff --git a/src/extractor/artists.rs b/src/extractor/artists.rs index 210af5e..d0ef9d5 100644 --- a/src/extractor/artists.rs +++ b/src/extractor/artists.rs @@ -4,8 +4,8 @@ use super::{Extractor, trim_whitespace, parse_date}; #[derive(Debug, Default)] pub struct Artist { - pub name: String, - pub url: String, + pub artist_name: String, + pub artist_url: String, pub date: String, pub author: String, pub author_url: String, @@ -39,8 +39,8 @@ impl Extractor for Artist { let author_url = author_el.value().attr("href").unwrap(); Self { - name: trim_whitespace(&title), - url: trim_whitespace(url), + artist_name: trim_whitespace(&title), + artist_url: trim_whitespace(url), date: parse_date(&date), author: trim_whitespace(&author), author_url: trim_whitespace(author_url), @@ -79,13 +79,13 @@ r#" assert_eq!(artists.len(), 2); assert_eq!(artists[0].author, "suji"); assert_eq!(artists[0].author_url, "/users/suji/"); - assert_eq!(artists[0].name, "BabyKingdom"); - assert_eq!(artists[0].url, "/artists/babykingdom/"); + assert_eq!(artists[0].artist_name, "BabyKingdom"); + assert_eq!(artists[0].artist_url, "/artists/babykingdom/"); assert_eq!(artists[0].date, "2022-06-16 14:12:03"); assert_eq!(artists[1].author, "kumika"); assert_eq!(artists[1].author_url, "/users/kumika/"); - assert_eq!(artists[1].name, "HIRO"); - assert_eq!(artists[1].url, "/artists/hiro-ruvish/"); + assert_eq!(artists[1].artist_name, "HIRO"); + assert_eq!(artists[1].artist_url, "/artists/hiro-ruvish/"); assert_eq!(artists[1].date, "2022-06-16 11:11:06"); } @@ -103,8 +103,8 @@ r#" let artist = Artist::extract(document); assert_eq!(artist.author, "suji"); assert_eq!(artist.author_url, "/users/suji/"); - assert_eq!(artist.name, "BabyKingdom"); - assert_eq!(artist.url, "/artists/babykingdom/"); + assert_eq!(artist.artist_name, "BabyKingdom"); + assert_eq!(artist.artist_url, "/artists/babykingdom/"); assert_eq!(artist.date, "2022-06-16 14:12:03"); } } \ No newline at end of file diff --git a/src/extractor/labels.rs b/src/extractor/labels.rs index da83e43..6a1e53f 100644 --- a/src/extractor/labels.rs +++ b/src/extractor/labels.rs @@ -4,8 +4,8 @@ use super::{Extractor, trim_whitespace, parse_date}; #[derive(Debug, Default)] pub struct Label { - pub name: String, - pub url: String, + pub artist_name: String, + pub artist_url: String, pub date: String, pub author: String, pub author_url: String, @@ -39,8 +39,8 @@ impl Extractor for Label { let author_url = author_el.value().attr("href").unwrap(); Self { - name: trim_whitespace(&title), - url: trim_whitespace(url), + artist_name: trim_whitespace(&title), + artist_url: trim_whitespace(url), date: parse_date(&date), author: trim_whitespace(&author), author_url: trim_whitespace(author_url), @@ -77,13 +77,13 @@ r#" let document = scraper::Html::parse_fragment(EXAMPLES); let artists = Label::extract_all(document); assert_eq!(artists.len(), 2); - assert_eq!(artists[0].name, "ARCANUMANIA Records."); - assert_eq!(artists[0].url, "/labels/arcanumania-records/"); + assert_eq!(artists[0].artist_name, "ARCANUMANIA Records."); + assert_eq!(artists[0].artist_url, "/labels/arcanumania-records/"); assert_eq!(artists[0].date, "2022-06-13 21:27:11"); assert_eq!(artists[0].author, "haru"); assert_eq!(artists[0].author_url, "/users/haru/"); - assert_eq!(artists[1].name, "Omega Code"); - assert_eq!(artists[1].url, "/labels/omega-code/"); + assert_eq!(artists[1].artist_name, "Omega Code"); + assert_eq!(artists[1].artist_url, "/labels/omega-code/"); assert_eq!(artists[1].date, "2022-06-12 18:43:41"); assert_eq!(artists[1].author, "inartistic"); assert_eq!(artists[1].author_url, "/users/inartistic/"); @@ -103,8 +103,8 @@ r#" let artist = Label::extract(document); assert_eq!(artist.author, "haru"); assert_eq!(artist.author_url, "/users/haru/"); - assert_eq!(artist.name, "ARCANUMANIA Records."); - assert_eq!(artist.url, "/labels/arcanumania-records/"); + assert_eq!(artist.artist_name, "ARCANUMANIA Records."); + assert_eq!(artist.artist_url, "/labels/arcanumania-records/"); assert_eq!(artist.date, "2022-06-13 21:27:11"); } } \ No newline at end of file diff --git a/src/extractor/musicians.rs b/src/extractor/musicians.rs index 274a5f1..61d77d7 100644 --- a/src/extractor/musicians.rs +++ b/src/extractor/musicians.rs @@ -4,8 +4,8 @@ use super::{Extractor, trim_whitespace, parse_date}; #[derive(Debug, Default)] pub struct Musician { - pub name: String, - pub url: String, + pub artist_name: String, + pub artist_url: String, pub date: String, pub author: String, pub author_url: String, @@ -39,8 +39,8 @@ impl Extractor for Musician { let author_url = author_el.value().attr("href").unwrap(); Self { - name: trim_whitespace(&title), - url: trim_whitespace(url), + artist_name: trim_whitespace(&title), + artist_url: trim_whitespace(url), date: parse_date(&date), author: trim_whitespace(&author), author_url: trim_whitespace(author_url), @@ -77,13 +77,13 @@ r#" let document = scraper::Html::parse_fragment(EXAMPLES); let artists = Musician::extract_all(document); assert_eq!(artists.len(), 2); - assert_eq!(artists[0].name, "HIKO"); - assert_eq!(artists[0].url, "/musicians/27075/hiko/"); + assert_eq!(artists[0].artist_name, "HIKO"); + assert_eq!(artists[0].artist_url, "/musicians/27075/hiko/"); assert_eq!(artists[0].date, "2022-06-16 14:12:02"); assert_eq!(artists[0].author, "suji"); assert_eq!(artists[0].author_url, "/users/suji/"); - assert_eq!(artists[1].name, "HIRO"); - assert_eq!(artists[1].url, "/musicians/6312/hiro/"); + assert_eq!(artists[1].artist_name, "HIRO"); + assert_eq!(artists[1].artist_url, "/musicians/6312/hiro/"); assert_eq!(artists[1].date, "2022-06-16 11:11:25"); assert_eq!(artists[1].author, "kumika"); assert_eq!(artists[1].author_url, "/users/kumika/"); @@ -101,8 +101,8 @@ r#" fn extract_must_be_return_correct_value() { let document = scraper::Html::parse_fragment(EXAMPLE); let artist = Musician::extract(document); - assert_eq!(artist.name, "HIRO"); - assert_eq!(artist.url, "/musicians/6312/hiro/"); + assert_eq!(artist.artist_name, "HIRO"); + assert_eq!(artist.artist_url, "/musicians/6312/hiro/"); assert_eq!(artist.date, "2022-06-16 11:11:25"); assert_eq!(artist.author, "kumika"); assert_eq!(artist.author_url, "/users/kumika/"); diff --git a/src/extractor/releases.rs b/src/extractor/releases.rs index 1f9838c..4a34711 100644 --- a/src/extractor/releases.rs +++ b/src/extractor/releases.rs @@ -4,8 +4,8 @@ use super::{Extractor, trim_whitespace, parse_date}; #[derive(Debug, Default)] pub struct Release { - pub name: String, - pub url: String, + pub artist_name: String, + pub artist_url: String, pub album: String, pub album_url: String, pub date: String, @@ -44,8 +44,8 @@ impl Extractor for Release { let author_url = author_el.value().attr("href").unwrap(); Self { - name: trim_whitespace(&title), - url: trim_whitespace(url), + artist_name: trim_whitespace(&title), + artist_url: trim_whitespace(url), album: trim_whitespace(&album), album_url: trim_whitespace(album_url), date: parse_date(&date), @@ -90,15 +90,15 @@ r#" let document = scraper::Html::parse_fragment(EXAMPLES); let artists = Release::extract_all(document); assert_eq!(artists.len(), 2); - assert_eq!(artists[0].name, "MUCC"); - assert_eq!(artists[0].url, "/artists/mucc/"); + assert_eq!(artists[0].artist_name, "MUCC"); + assert_eq!(artists[0].artist_url, "/artists/mucc/"); assert_eq!(artists[0].album, "Shin Sekai Tsuujouban"); assert_eq!(artists[0].album_url, "/releases/mucc/54429/shin-sekai-tsuujouban/"); assert_eq!(artists[0].date, "2022-06-16 12:21:00"); assert_eq!(artists[0].author, "kumika"); assert_eq!(artists[0].author_url, "/users/kumika/"); - assert_eq!(artists[1].name, "LAY ABOUT WORLD"); - assert_eq!(artists[1].url, "/artists/lay-about-world/"); + assert_eq!(artists[1].artist_name, "LAY ABOUT WORLD"); + assert_eq!(artists[1].artist_url, "/artists/lay-about-world/"); assert_eq!(artists[1].album, "c×lone"); assert_eq!(artists[1].album_url, "/releases/lay-about-world/37128/c-lone/"); assert_eq!(artists[1].date, "2022-06-16 11:39:52"); @@ -121,8 +121,8 @@ r#" fn extract_must_be_return_correct_value() { let document = scraper::Html::parse_fragment(EXAMPLE); let artist = Release::extract(document); - assert_eq!(artist.name, "MUCC"); - assert_eq!(artist.url, "/artists/mucc/"); + assert_eq!(artist.artist_name, "MUCC"); + assert_eq!(artist.artist_url, "/artists/mucc/"); assert_eq!(artist.album, "Shin Sekai Tsuujouban"); assert_eq!(artist.album_url, "/releases/mucc/54429/shin-sekai-tsuujouban/"); assert_eq!(artist.date, "2022-06-16 12:21:00");