Add uploadDate to the playlist info
This commit is contained in:
parent
e88c0abdeb
commit
8b08a8b4fc
|
@ -1,6 +1,7 @@
|
||||||
package org.schabi.newpipe.extractor.playlist;
|
package org.schabi.newpipe.extractor.playlist;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
|
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
@ -14,6 +15,10 @@ public class PlaylistInfoItem extends InfoItem {
|
||||||
*/
|
*/
|
||||||
private long streamCount = 0;
|
private long streamCount = 0;
|
||||||
private PlaylistInfo.PlaylistType playlistType;
|
private PlaylistInfo.PlaylistType playlistType;
|
||||||
|
@Nullable
|
||||||
|
private String textualUploadDate;
|
||||||
|
@Nullable
|
||||||
|
private DateWrapper uploadDate;
|
||||||
|
|
||||||
public PlaylistInfoItem(final int serviceId, final String url, final String name) {
|
public PlaylistInfoItem(final int serviceId, final String url, final String name) {
|
||||||
super(InfoType.PLAYLIST, serviceId, url, name);
|
super(InfoType.PLAYLIST, serviceId, url, name);
|
||||||
|
@ -59,4 +64,20 @@ public class PlaylistInfoItem extends InfoItem {
|
||||||
public void setPlaylistType(final PlaylistInfo.PlaylistType playlistType) {
|
public void setPlaylistType(final PlaylistInfo.PlaylistType playlistType) {
|
||||||
this.playlistType = playlistType;
|
this.playlistType = playlistType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTextualUploadDate() {
|
||||||
|
return textualUploadDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextualUploadDate(final String textualUploadDate) {
|
||||||
|
this.textualUploadDate = textualUploadDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateWrapper getUploadDate() {
|
||||||
|
return uploadDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUploadDate(final DateWrapper uploadDate) {
|
||||||
|
this.uploadDate = uploadDate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package org.schabi.newpipe.extractor.playlist;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.InfoItemExtractor;
|
import org.schabi.newpipe.extractor.InfoItemExtractor;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
@ -39,4 +40,12 @@ public interface PlaylistInfoItemExtractor extends InfoItemExtractor {
|
||||||
default PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException {
|
default PlaylistInfo.PlaylistType getPlaylistType() throws ParsingException {
|
||||||
return PlaylistInfo.PlaylistType.NORMAL;
|
return PlaylistInfo.PlaylistType.NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default String getTextualUploadDate() throws ParsingException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
default DateWrapper getUploadDate() throws ParsingException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,16 @@ public class PlaylistInfoItemsCollector
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
resultItem.setTextualUploadDate(extractor.getTextualUploadDate());
|
||||||
|
} catch (final Exception e) {
|
||||||
|
addError(e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
resultItem.setUploadDate(extractor.getUploadDate());
|
||||||
|
} catch (final Exception e) {
|
||||||
|
addError(e);
|
||||||
|
}
|
||||||
return resultItem;
|
return resultItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package org.schabi.newpipe.extractor.services.youtube.extractors;
|
package org.schabi.newpipe.extractor.services.youtube.extractors;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
import org.schabi.newpipe.extractor.localization.DateWrapper;
|
||||||
|
import org.schabi.newpipe.extractor.localization.Localization;
|
||||||
|
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
|
||||||
|
import org.schabi.newpipe.extractor.localization.TimeAgoPatternsManager;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor;
|
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
|
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
|
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubePlaylistLinkHandlerFactory;
|
||||||
|
@ -60,5 +64,21 @@ public class GridPlaylistRendererExtractor implements PlaylistInfoItemExtractor
|
||||||
return Long.parseLong(
|
return Long.parseLong(
|
||||||
playlistInfoItem.getObject("videoCountShortText").getString("simpleText"));
|
playlistInfoItem.getObject("videoCountShortText").getString("simpleText"));
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public String getTextualUploadDate() throws ParsingException {
|
||||||
|
return playlistInfoItem.getObject("publishedTimeText").getString("simpleText");
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public DateWrapper getUploadDate() throws ParsingException {
|
||||||
|
final String uploadDate = getTextualUploadDate();
|
||||||
|
if (uploadDate != null) {
|
||||||
|
if (uploadDate.startsWith("Updated ")) {
|
||||||
|
final TimeAgoParser timeAgoParser = TimeAgoPatternsManager.getTimeAgoParserFor(
|
||||||
|
Localization.fromLocalizationCode("en"));
|
||||||
|
return timeAgoParser.parse(uploadDate.substring(8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue