Ignore deleted playlist items and add uploader url

This commit is contained in:
Coffeemakr 2017-11-25 03:14:15 +01:00
parent c9eb790d1c
commit d59618d0e7
No known key found for this signature in database
GPG Key ID: 3F35676D8FF6E743
2 changed files with 47 additions and 1 deletions

View File

@ -203,7 +203,13 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
final UrlIdHandler streamUrlIdHandler = getService().getStreamUrlIdHandler();
for (final Element li : element.children()) {
if(isDeletedItem(li)) {
continue;
}
collector.commit(new YoutubeStreamInfoItemExtractor(li) {
public Element uploaderLink;
@Override
public boolean isAd() throws ParsingException {
return false;
@ -245,9 +251,23 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
}
}
private Element getUploaderLink() {
// should always be present since we filter deleted items
if(uploaderLink == null) {
uploaderLink = li.select("div[class=pl-video-owner] a").first();
}
return uploaderLink;
}
@Override
public String getUploaderName() throws ParsingException {
return li.select("div[class=pl-video-owner] a").text();
return getUploaderLink().text();
}
@Override
public String getUploaderUrl() throws ParsingException {
return getUploaderLink().attr("href");
}
@Override
@ -271,4 +291,13 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
});
}
}
/**
* Check if the playlist item is deleted
* @param li the list item
* @return true if the item is deleted
*/
private boolean isDeletedItem(Element li) {
return li.select("div[class=pl-video-owner] a").isEmpty();
}
}

View File

@ -83,4 +83,21 @@ public class StreamInfoItem extends InfoItem {
public void setViewCount(long view_count) {
this.view_count = view_count;
}
@Override
public String toString() {
return "StreamInfoItem{" +
"stream_type=" + stream_type +
", uploader_name='" + uploader_name + '\'' +
", upload_date='" + upload_date + '\'' +
", view_count=" + view_count +
", duration=" + duration +
", uploaderUrl='" + uploaderUrl + '\'' +
", info_type=" + info_type +
", service_id=" + service_id +
", url='" + url + '\'' +
", name='" + name + '\'' +
", thumbnail_url='" + thumbnail_url + '\'' +
'}';
}
}