simplify retrieval of Entries
This commit is contained in:
35
goutubedl.go
35
goutubedl.go
@ -454,30 +454,31 @@ func infoFromURL(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// as we ignore errors for playlists some entries might show up as null
|
// as we ignore errors for playlists some entries might show up as null
|
||||||
if options.Type == TypePlaylist {
|
//
|
||||||
|
// note: instead of doing full recursion, we assume entries in
|
||||||
|
// playlists and channels are at most 2 levels deep, and we just
|
||||||
|
// collect entries from both levels.
|
||||||
|
//
|
||||||
|
// the following cases have not been tested:
|
||||||
|
//
|
||||||
|
// - entries that are more than 2 levels deep (will be missed)
|
||||||
|
// - the ability to restrict entries to a single level (we include both levels)
|
||||||
|
if options.Type == TypePlaylist || options.Type == TypeChannel {
|
||||||
var filteredEntrise []Info
|
var filteredEntrise []Info
|
||||||
for _, e := range info.Entries {
|
for _, e := range info.Entries {
|
||||||
if e.ID == "" {
|
if e.ID == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
filteredEntrise = append(filteredEntrise, e)
|
if e.Type == "playlist" {
|
||||||
}
|
for _, ee := range e.Entries {
|
||||||
info.Entries = filteredEntrise
|
if ee.ID == "" {
|
||||||
}
|
continue
|
||||||
|
}
|
||||||
// channels contain playlists, so recurse into them
|
filteredEntrise = append(filteredEntrise, ee)
|
||||||
if options.Type == TypeChannel {
|
}
|
||||||
var filteredEntrise []Info
|
|
||||||
for _, p := range info.Entries {
|
|
||||||
if p.Type != "playlist" {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, e := range p.Entries {
|
filteredEntrise = append(filteredEntrise, e)
|
||||||
if e.ID == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
filteredEntrise = append(filteredEntrise, e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
info.Entries = filteredEntrise
|
info.Entries = filteredEntrise
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user