Ignore deleted playlist items and add uploader url
This commit is contained in:
parent
c9eb790d1c
commit
d59618d0e7
2 changed files with 47 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue