Skip to content

Commit d59618d

Browse files
committed
Ignore deleted playlist items and add uploader url
1 parent c9eb790 commit d59618d

2 files changed

Lines changed: 47 additions & 1 deletion

File tree

src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractor.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@ private void collectStreamsFrom(StreamInfoItemCollector collector, Element eleme
203203

204204
final UrlIdHandler streamUrlIdHandler = getService().getStreamUrlIdHandler();
205205
for (final Element li : element.children()) {
206+
if(isDeletedItem(li)) {
207+
continue;
208+
}
209+
206210
collector.commit(new YoutubeStreamInfoItemExtractor(li) {
211+
public Element uploaderLink;
212+
207213
@Override
208214
public boolean isAd() throws ParsingException {
209215
return false;
@@ -245,9 +251,23 @@ public long getDuration() throws ParsingException {
245251
}
246252
}
247253

254+
255+
private Element getUploaderLink() {
256+
// should always be present since we filter deleted items
257+
if(uploaderLink == null) {
258+
uploaderLink = li.select("div[class=pl-video-owner] a").first();
259+
}
260+
return uploaderLink;
261+
}
262+
248263
@Override
249264
public String getUploaderName() throws ParsingException {
250-
return li.select("div[class=pl-video-owner] a").text();
265+
return getUploaderLink().text();
266+
}
267+
268+
@Override
269+
public String getUploaderUrl() throws ParsingException {
270+
return getUploaderLink().attr("href");
251271
}
252272

253273
@Override
@@ -271,4 +291,13 @@ public String getThumbnailUrl() throws ParsingException {
271291
});
272292
}
273293
}
294+
295+
/**
296+
* Check if the playlist item is deleted
297+
* @param li the list item
298+
* @return true if the item is deleted
299+
*/
300+
private boolean isDeletedItem(Element li) {
301+
return li.select("div[class=pl-video-owner] a").isEmpty();
302+
}
274303
}

src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,21 @@ public void setUploadDate(String upload_date) {
8383
public void setViewCount(long view_count) {
8484
this.view_count = view_count;
8585
}
86+
87+
@Override
88+
public String toString() {
89+
return "StreamInfoItem{" +
90+
"stream_type=" + stream_type +
91+
", uploader_name='" + uploader_name + '\'' +
92+
", upload_date='" + upload_date + '\'' +
93+
", view_count=" + view_count +
94+
", duration=" + duration +
95+
", uploaderUrl='" + uploaderUrl + '\'' +
96+
", info_type=" + info_type +
97+
", service_id=" + service_id +
98+
", url='" + url + '\'' +
99+
", name='" + name + '\'' +
100+
", thumbnail_url='" + thumbnail_url + '\'' +
101+
'}';
102+
}
86103
}

0 commit comments

Comments
 (0)