Compare commits
4 commits
1bab2ef301
...
375c08d11b
Author | SHA1 | Date | |
---|---|---|---|
375c08d11b | |||
b18698604b | |||
8ea69d5453 | |||
031b730c47 |
12 changed files with 87 additions and 79 deletions
|
@ -173,7 +173,6 @@ enum MusicSearchCategory {
|
||||||
Videos,
|
Videos,
|
||||||
Artists,
|
Artists,
|
||||||
Albums,
|
Albums,
|
||||||
Playlists,
|
|
||||||
PlaylistsYtm,
|
PlaylistsYtm,
|
||||||
PlaylistsCommunity,
|
PlaylistsCommunity,
|
||||||
}
|
}
|
||||||
|
@ -676,15 +675,10 @@ async fn main() {
|
||||||
res.items.extend_limit(rp.query(), limit).await.unwrap();
|
res.items.extend_limit(rp.query(), limit).await.unwrap();
|
||||||
print_data(&res, format, pretty);
|
print_data(&res, format, pretty);
|
||||||
}
|
}
|
||||||
Some(MusicSearchCategory::Playlists) => {
|
|
||||||
let mut res = rp.query().music_search_playlists(&query).await.unwrap();
|
|
||||||
res.items.extend_limit(rp.query(), limit).await.unwrap();
|
|
||||||
print_data(&res, format, pretty);
|
|
||||||
}
|
|
||||||
Some(MusicSearchCategory::PlaylistsYtm) => {
|
Some(MusicSearchCategory::PlaylistsYtm) => {
|
||||||
let mut res = rp
|
let mut res = rp
|
||||||
.query()
|
.query()
|
||||||
.music_search_playlists_filter(&query, false)
|
.music_search_playlists(&query, false)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
res.items.extend_limit(rp.query(), limit).await.unwrap();
|
res.items.extend_limit(rp.query(), limit).await.unwrap();
|
||||||
|
@ -693,7 +687,7 @@ async fn main() {
|
||||||
Some(MusicSearchCategory::PlaylistsCommunity) => {
|
Some(MusicSearchCategory::PlaylistsCommunity) => {
|
||||||
let mut res = rp
|
let mut res = rp
|
||||||
.query()
|
.query()
|
||||||
.music_search_playlists_filter(&query, true)
|
.music_search_playlists(&query, true)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
res.items.extend_limit(rp.query(), limit).await.unwrap();
|
res.items.extend_limit(rp.query(), limit).await.unwrap();
|
||||||
|
|
|
@ -11,7 +11,9 @@ tokio = { version = "1.20.0", features = ["macros", "rt-multi-thread"] }
|
||||||
futures = "0.3.21"
|
futures = "0.3.21"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0.82"
|
serde_json = "1.0.82"
|
||||||
serde_with = { version = "3.0.0", default-features = false, features = ["macros"] }
|
serde_with = { version = "3.0.0", default-features = false, features = [
|
||||||
|
"macros",
|
||||||
|
] }
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
log = "0.4.17"
|
log = "0.4.17"
|
||||||
env_logger = "0.10.0"
|
env_logger = "0.10.0"
|
||||||
|
@ -24,3 +26,4 @@ num_enum = "0.6.1"
|
||||||
path_macro = "1.0.0"
|
path_macro = "1.0.0"
|
||||||
intl_pluralrules = "7.0.2"
|
intl_pluralrules = "7.0.2"
|
||||||
unic-langid = "0.9.1"
|
unic-langid = "0.9.1"
|
||||||
|
ordered_hash_map = { version = "0.2.0", features = ["serde"] }
|
||||||
|
|
|
@ -24,6 +24,7 @@ pub enum ABTest {
|
||||||
TrendsPageHeaderRenderer = 5,
|
TrendsPageHeaderRenderer = 5,
|
||||||
DiscographyPage = 6,
|
DiscographyPage = 6,
|
||||||
ShortDateFormat = 7,
|
ShortDateFormat = 7,
|
||||||
|
PlaylistsForShorts = 9,
|
||||||
}
|
}
|
||||||
|
|
||||||
const TESTS_TO_RUN: [ABTest; 3] = [
|
const TESTS_TO_RUN: [ABTest; 3] = [
|
||||||
|
@ -94,6 +95,7 @@ pub async fn run_test(
|
||||||
ABTest::TrendsPageHeaderRenderer => trends_page_header_renderer(&query).await,
|
ABTest::TrendsPageHeaderRenderer => trends_page_header_renderer(&query).await,
|
||||||
ABTest::DiscographyPage => discography_page(&query).await,
|
ABTest::DiscographyPage => discography_page(&query).await,
|
||||||
ABTest::ShortDateFormat => short_date_format(&query).await,
|
ABTest::ShortDateFormat => short_date_format(&query).await,
|
||||||
|
ABTest::PlaylistsForShorts => playlists_for_shorts(&query).await,
|
||||||
}
|
}
|
||||||
.unwrap();
|
.unwrap();
|
||||||
pb.inc(1);
|
pb.inc(1);
|
||||||
|
@ -243,3 +245,13 @@ pub async fn short_date_format(rp: &RustyPipeQuery) -> Result<bool> {
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn playlists_for_shorts(rp: &RustyPipeQuery) -> Result<bool> {
|
||||||
|
let playlist = rp.playlist("UUSHh8gHdtzO2tXd593_bjErWg").await?;
|
||||||
|
let v1 = playlist
|
||||||
|
.videos
|
||||||
|
.items
|
||||||
|
.first()
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("no videos"))?;
|
||||||
|
Ok(v1.publish_date_txt.is_none())
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures::{stream, StreamExt};
|
use futures::{stream, StreamExt};
|
||||||
|
use ordered_hash_map::OrderedHashMap;
|
||||||
use path_macro::path;
|
use path_macro::path;
|
||||||
use rustypipe::{
|
use rustypipe::{
|
||||||
client::RustyPipe,
|
client::RustyPipe,
|
||||||
|
@ -170,7 +171,7 @@ pub fn write_samples_to_dict() {
|
||||||
dict_entry.months = BTreeMap::new();
|
dict_entry.months = BTreeMap::new();
|
||||||
|
|
||||||
if collect_nd_tokens {
|
if collect_nd_tokens {
|
||||||
dict_entry.timeago_nd_tokens = BTreeMap::new();
|
dict_entry.timeago_nd_tokens = OrderedHashMap::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
for datestr_table in &datestr_tables {
|
for datestr_table in &datestr_tables {
|
||||||
|
|
|
@ -619,7 +619,7 @@ async fn music_search_playlists() {
|
||||||
|
|
||||||
let rp = rp_testfile(&json_path);
|
let rp = rp_testfile(&json_path);
|
||||||
rp.query()
|
rp.query()
|
||||||
.music_search_playlists_filter("pop", community)
|
.music_search_playlists("pop", community)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use ordered_hash_map::OrderedHashMap;
|
||||||
use rustypipe::{client::YTContext, model::AlbumType, param::Language};
|
use rustypipe::{client::YTContext, model::AlbumType, param::Language};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_with::{serde_as, DefaultOnError, VecSkipError};
|
use serde_with::{serde_as, DefaultOnError, VecSkipError};
|
||||||
|
@ -18,7 +19,7 @@ pub struct DictEntry {
|
||||||
///
|
///
|
||||||
/// Identifiers: `Y`(ear), `M`(month), `W`(eek), `D`(ay),
|
/// Identifiers: `Y`(ear), `M`(month), `W`(eek), `D`(ay),
|
||||||
/// `h`(our), `m`(inute), `s`(econd)
|
/// `h`(our), `m`(inute), `s`(econd)
|
||||||
pub timeago_tokens: BTreeMap<String, String>,
|
pub timeago_tokens: OrderedHashMap<String, String>,
|
||||||
/// Order in which to parse numeric date components. Formatted as
|
/// Order in which to parse numeric date components. Formatted as
|
||||||
/// a string of date identifiers (Y, M, D).
|
/// a string of date identifiers (Y, M, D).
|
||||||
///
|
///
|
||||||
|
@ -34,7 +35,7 @@ pub struct DictEntry {
|
||||||
/// Tokens for parsing date strings with no digits (e.g. Today, Tomorrow)
|
/// Tokens for parsing date strings with no digits (e.g. Today, Tomorrow)
|
||||||
///
|
///
|
||||||
/// Format: Parsed token -> \[Quantity\] Identifier
|
/// Format: Parsed token -> \[Quantity\] Identifier
|
||||||
pub timeago_nd_tokens: BTreeMap<String, String>,
|
pub timeago_nd_tokens: OrderedHashMap<String, String>,
|
||||||
/// Are commas (instead of points) used as decimal separators?
|
/// Are commas (instead of points) used as decimal separators?
|
||||||
pub comma_decimal: bool,
|
pub comma_decimal: bool,
|
||||||
/// Tokens for parsing decimal prefixes (K, M, B, ...)
|
/// Tokens for parsing decimal prefixes (K, M, B, ...)
|
||||||
|
@ -49,6 +50,10 @@ pub struct DictEntry {
|
||||||
///
|
///
|
||||||
/// Format: Parsed text -> Album type
|
/// Format: Parsed text -> Album type
|
||||||
pub album_types: BTreeMap<String, AlbumType>,
|
pub album_types: BTreeMap<String, AlbumType>,
|
||||||
|
/// Names of item types (Song, Video, Artist, Playlist)
|
||||||
|
///
|
||||||
|
/// Format: Parsed text -> Item type
|
||||||
|
pub item_types: BTreeMap<String, ExtItemType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parsed TimeAgo string, contains amount and time unit.
|
/// Parsed TimeAgo string, contains amount and time unit.
|
||||||
|
@ -99,6 +104,15 @@ impl TimeUnit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
pub enum ExtItemType {
|
||||||
|
Track,
|
||||||
|
Video,
|
||||||
|
Episode,
|
||||||
|
Playlist,
|
||||||
|
Artist,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct QBrowse<'a> {
|
pub struct QBrowse<'a> {
|
||||||
|
|
|
@ -360,8 +360,8 @@ YouTube changed the header renderer type on the trending page to a `pageHeaderRe
|
||||||
- **Impact:** 🟡 Medium
|
- **Impact:** 🟡 Medium
|
||||||
- **Endpoint:** browse (music artist)
|
- **Endpoint:** browse (music artist)
|
||||||
|
|
||||||
YouTube merged the 2 sections for singles and albums on artist pages together. Now
|
YouTube merged the 2 sections for singles and albums on artist pages together. Now there
|
||||||
there is only a *Top Releases* section.
|
is only a _Top Releases_ section.
|
||||||
|
|
||||||
YouTube also changed the way the full discography page is fetched, surprisingly making
|
YouTube also changed the way the full discography page is fetched, surprisingly making
|
||||||
it easier for alternative clients. The discography page now has its own content ID in
|
it easier for alternative clients. The discography page now has its own content ID in
|
||||||
|
@ -382,5 +382,26 @@ visitor data cookie to be set, as it was the case with the old system.
|
||||||
- **Encountered on:** 28.05.2023
|
- **Encountered on:** 28.05.2023
|
||||||
- **Impact:** 🟡 Medium
|
- **Impact:** 🟡 Medium
|
||||||
|
|
||||||
YouTube changed their date format from the long format (*21 hours ago*, *3 days ago*) to
|
YouTube changed their date format from the long format (_21 hours ago_, _3 days ago_) to
|
||||||
a short format (*21h ago*, *3d ago*).
|
a short format (_21h ago_, _3d ago_).
|
||||||
|
|
||||||
|
## [9] Playlists for Shorts
|
||||||
|
|
||||||
|
- **Encountered on:** 26.06.2023
|
||||||
|
- **Impact:** 🟡 Medium
|
||||||
|
- **Endpoint:** browse (playlist)
|
||||||
|
|
||||||
|
![A/B test 9 screenshot](./_img/ab_9.png)
|
||||||
|
|
||||||
|
Original issue: https://github.com/TeamNewPipe/NewPipeExtractor/issues/10774
|
||||||
|
|
||||||
|
YouTube added a filter system for playlists, allowing users to only see shorts/full
|
||||||
|
videos.
|
||||||
|
|
||||||
|
When shorts filter is enabled or when there are only shorts in a playlist, YouTube
|
||||||
|
return shorts UI elements instead of standard video ones, the ones that are also used
|
||||||
|
for shorts shelves in searches and suggestions and shorts in the corresponding channel
|
||||||
|
tab.
|
||||||
|
|
||||||
|
Since the reel items dont include upload date information you can circumvent this new UI
|
||||||
|
by using the mobile client. But that may change in the future.
|
||||||
|
|
BIN
notes/_img/ab_9.png
Normal file
BIN
notes/_img/ab_9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 550 KiB |
|
@ -40,8 +40,6 @@ enum Params {
|
||||||
Albums,
|
Albums,
|
||||||
#[serde(rename = "EgWKAQIgAWoMEAMQBBAJEA4QChAF")]
|
#[serde(rename = "EgWKAQIgAWoMEAMQBBAJEA4QChAF")]
|
||||||
Artists,
|
Artists,
|
||||||
#[serde(rename = "EgWKAQIoAWoMEAMQBBAJEA4QChAF")]
|
|
||||||
Playlists,
|
|
||||||
#[serde(rename = "EgeKAQQoADgBagwQAxAEEAkQDhAKEAU%3D")]
|
#[serde(rename = "EgeKAQQoADgBagwQAxAEEAkQDhAKEAU%3D")]
|
||||||
YtmPlaylists,
|
YtmPlaylists,
|
||||||
#[serde(rename = "EgeKAQQoAEABagwQAxAEEAkQDhAKEAU%3D")]
|
#[serde(rename = "EgeKAQQoAEABagwQAxAEEAkQDhAKEAU%3D")]
|
||||||
|
@ -152,44 +150,25 @@ impl RustyPipeQuery {
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Search YouTube Music playlists
|
/// Search YouTube Music playlists
|
||||||
|
///
|
||||||
|
/// Playlists are filtered whether they are created by users
|
||||||
|
/// (`community=true`) or by YouTube Music (`community=false`)
|
||||||
pub async fn music_search_playlists<S: AsRef<str>>(
|
pub async fn music_search_playlists<S: AsRef<str>>(
|
||||||
&self,
|
&self,
|
||||||
query: S,
|
query: S,
|
||||||
) -> Result<MusicSearchFiltered<MusicPlaylistItem>, Error> {
|
|
||||||
self._music_search_playlists(query, Params::Playlists).await
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Search YouTube Music playlists that were created by users
|
|
||||||
/// (`community=true`) or by YouTube Music (`community=false`)
|
|
||||||
pub async fn music_search_playlists_filter<S: AsRef<str>>(
|
|
||||||
&self,
|
|
||||||
query: S,
|
|
||||||
community: bool,
|
community: bool,
|
||||||
) -> Result<MusicSearchFiltered<MusicPlaylistItem>, Error> {
|
|
||||||
self._music_search_playlists(
|
|
||||||
query,
|
|
||||||
if community {
|
|
||||||
Params::CommunityPlaylists
|
|
||||||
} else {
|
|
||||||
Params::YtmPlaylists
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn _music_search_playlists<S: AsRef<str>>(
|
|
||||||
&self,
|
|
||||||
query: S,
|
|
||||||
params: Params,
|
|
||||||
) -> Result<MusicSearchFiltered<MusicPlaylistItem>, Error> {
|
) -> Result<MusicSearchFiltered<MusicPlaylistItem>, Error> {
|
||||||
let query = query.as_ref();
|
let query = query.as_ref();
|
||||||
let context = self.get_context(ClientType::DesktopMusic, true, None).await;
|
let context = self.get_context(ClientType::DesktopMusic, true, None).await;
|
||||||
let request_body = QSearch {
|
let request_body = QSearch {
|
||||||
context,
|
context,
|
||||||
query,
|
query,
|
||||||
params: Some(params),
|
params: Some(if community {
|
||||||
|
Params::CommunityPlaylists
|
||||||
|
} else {
|
||||||
|
Params::YtmPlaylists
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.execute_request::<response::MusicSearch, _, _>(
|
self.execute_request::<response::MusicSearch, _, _>(
|
||||||
|
|
|
@ -29,6 +29,7 @@ pub(crate) struct ItemSection {
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub(crate) struct PlaylistVideoListRenderer {
|
pub(crate) struct PlaylistVideoListRenderer {
|
||||||
|
#[serde(alias = "richGridRenderer")]
|
||||||
pub playlist_video_list_renderer: YouTubeListRenderer,
|
pub playlist_video_list_renderer: YouTubeListRenderer,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub static VIDEO_ID_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"^[A-Za-z0-9_-
|
||||||
pub static CHANNEL_ID_REGEX: Lazy<Regex> =
|
pub static CHANNEL_ID_REGEX: Lazy<Regex> =
|
||||||
Lazy::new(|| Regex::new(r"^UC[A-Za-z0-9_-]{22}$").unwrap());
|
Lazy::new(|| Regex::new(r"^UC[A-Za-z0-9_-]{22}$").unwrap());
|
||||||
pub static PLAYLIST_ID_REGEX: Lazy<Regex> =
|
pub static PLAYLIST_ID_REGEX: Lazy<Regex> =
|
||||||
Lazy::new(|| Regex::new(r"^(?:PL|RD|OLAK|UU)[A-Za-z0-9_-]{16,50}$").unwrap());
|
Lazy::new(|| Regex::new(r"^(?:PL|RD|OLAK|UU)[A-Za-z0-9_-]{5,50}$").unwrap());
|
||||||
pub static ALBUM_ID_REGEX: Lazy<Regex> =
|
pub static ALBUM_ID_REGEX: Lazy<Regex> =
|
||||||
Lazy::new(|| Regex::new(r"^MPREb_[A-Za-z0-9_-]{11}$").unwrap());
|
Lazy::new(|| Regex::new(r"^MPREb_[A-Za-z0-9_-]{11}$").unwrap());
|
||||||
pub static VANITY_PATH_REGEX: Lazy<Regex> = Lazy::new(|| {
|
pub static VANITY_PATH_REGEX: Lazy<Regex> = Lazy::new(|| {
|
||||||
|
|
|
@ -1808,18 +1808,12 @@ fn music_search_artists_cont(rp: RustyPipe) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[case::ytm(false)]
|
fn music_search_playlists(rp: RustyPipe, unlocalized: bool) {
|
||||||
#[case::default(true)]
|
let res = tokio_test::block_on(
|
||||||
fn music_search_playlists(#[case] with_community: bool, rp: RustyPipe, unlocalized: bool) {
|
|
||||||
let res = if with_community {
|
|
||||||
tokio_test::block_on(rp.query().music_search_playlists("today's rock hits")).unwrap()
|
|
||||||
} else {
|
|
||||||
tokio_test::block_on(
|
|
||||||
rp.query()
|
rp.query()
|
||||||
.music_search_playlists_filter("today's rock hits", false),
|
.music_search_playlists("today's rock hits", false),
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap();
|
||||||
};
|
|
||||||
|
|
||||||
assert_eq!(res.corrected_query, None);
|
assert_eq!(res.corrected_query, None);
|
||||||
let playlist = res
|
let playlist = res
|
||||||
|
@ -1837,24 +1831,17 @@ fn music_search_playlists(#[case] with_community: bool, rp: RustyPipe, unlocaliz
|
||||||
assert_eq!(playlist.channel, None);
|
assert_eq!(playlist.channel, None);
|
||||||
assert!(playlist.from_ytm);
|
assert!(playlist.from_ytm);
|
||||||
|
|
||||||
if with_community {
|
|
||||||
assert!(
|
|
||||||
res.items.items.iter().any(|p| !p.from_ytm),
|
|
||||||
"no community items found"
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
assert!(
|
assert!(
|
||||||
res.items.items.iter().all(|p| p.from_ytm),
|
res.items.items.iter().all(|p| p.from_ytm),
|
||||||
"community items found"
|
"community items found"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn music_search_playlists_community(rp: RustyPipe) {
|
fn music_search_playlists_community(rp: RustyPipe) {
|
||||||
let res = tokio_test::block_on(
|
let res = tokio_test::block_on(
|
||||||
rp.query()
|
rp.query()
|
||||||
.music_search_playlists_filter("Best Pop Music Videos - Top Pop Hits Playlist", true),
|
.music_search_playlists("Best Pop Music Videos - Top Pop Hits Playlist", true),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -2241,14 +2228,10 @@ fn music_genre(#[case] id: &str, #[case] name: &str, rp: RustyPipe, unlocalized:
|
||||||
assert!(!playlist.thumbnail.is_empty(), "got no cover");
|
assert!(!playlist.thumbnail.is_empty(), "got no cover");
|
||||||
|
|
||||||
if !playlist.from_ytm {
|
if !playlist.from_ytm {
|
||||||
assert!(
|
if let Some(channel) = playlist.channel.as_ref() {
|
||||||
playlist.channel.is_some(),
|
|
||||||
"pl: {}, got no channel",
|
|
||||||
playlist.id
|
|
||||||
);
|
|
||||||
let channel = playlist.channel.as_ref().unwrap();
|
|
||||||
validate::channel_id(&channel.id).unwrap();
|
validate::channel_id(&channel.id).unwrap();
|
||||||
assert!(!channel.name.is_empty());
|
assert!(!channel.name.is_empty());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assert!(playlist.channel.is_none());
|
assert!(playlist.channel.is_none());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue