mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Handle YouTube URLs in format watch?v=XXX&list=YYY
This commit is contained in:
@@ -54,7 +54,8 @@ func parseYoutubeURL(parsed *url.URL) (kind api.LinkType, id string, err error)
|
|||||||
path := parsed.EscapedPath()
|
path := parsed.EscapedPath()
|
||||||
|
|
||||||
// https://www.youtube.com/playlist?list=PLCB9F975ECF01953C
|
// https://www.youtube.com/playlist?list=PLCB9F975ECF01953C
|
||||||
if strings.HasPrefix(path, "/playlist") {
|
// https://www.youtube.com/watch?v=rbCbho7aLYw&list=PLMpEfaKcGjpWEgNtdnsvLX6LzQL0UC0EM
|
||||||
|
if strings.HasPrefix(path, "/playlist") || strings.HasPrefix(path, "/watch") {
|
||||||
kind = api.Playlist
|
kind = api.Playlist
|
||||||
|
|
||||||
id = parsed.Query().Get("list")
|
id = parsed.Query().Get("list")
|
||||||
|
@@ -14,6 +14,12 @@ func TestParseYoutubeURL_Playlist(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, api.Playlist, kind)
|
require.Equal(t, api.Playlist, kind)
|
||||||
require.Equal(t, "PLCB9F975ECF01953C", id)
|
require.Equal(t, "PLCB9F975ECF01953C", id)
|
||||||
|
|
||||||
|
link, _ = url.ParseRequestURI("https://www.youtube.com/watch?v=rbCbho7aLYw&list=PLMpEfaKcGjpWEgNtdnsvLX6LzQL0UC0EM")
|
||||||
|
kind, id, err = parseYoutubeURL(link)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, api.Playlist, kind)
|
||||||
|
require.Equal(t, "PLMpEfaKcGjpWEgNtdnsvLX6LzQL0UC0EM", id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParseYoutubeURL_Channel(t *testing.T) {
|
func TestParseYoutubeURL_Channel(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user