format date of comment published. changed default instance
This commit is contained in:
parent
df0db8468d
commit
8755c25349
|
@ -18,7 +18,7 @@ public class PeertubeInstance {
|
||||||
|
|
||||||
private final String url;
|
private final String url;
|
||||||
private String name;
|
private String name;
|
||||||
public static final PeertubeInstance defaultInstance = new PeertubeInstance("https://peertube.mastodon.host", "PeerTube on Mastodon.host");
|
public static final PeertubeInstance defaultInstance = new PeertubeInstance("https://framatube.org", "FramaTube");
|
||||||
|
|
||||||
public PeertubeInstance(String url) throws IOException {
|
public PeertubeInstance(String url) throws IOException {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
package org.schabi.newpipe.extractor.services.peertube.extractors;
|
package org.schabi.newpipe.extractor.services.peertube.extractors;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.ServiceList;
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItemExtractor;
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItemExtractor;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
@ -42,7 +47,8 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPublishedTime() throws ParsingException {
|
public String getPublishedTime() throws ParsingException {
|
||||||
return JsonUtils.getString(item, "createdAt");
|
String date = JsonUtils.getString(item, "createdAt");
|
||||||
|
return getFormattedDate(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -85,4 +91,14 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
|
||||||
return PeertubeChannelLinkHandlerFactory.getInstance().fromId(name + "@" + host).getUrl();
|
return PeertubeChannelLinkHandlerFactory.getInstance().fromId(name + "@" + host).getUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getFormattedDate(String date) {
|
||||||
|
DateFormat sourceDf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
||||||
|
DateFormat targetDf = new SimpleDateFormat("dd-MM-yyyy hh:mm a", Locale.ENGLISH);
|
||||||
|
try {
|
||||||
|
return targetDf.format(sourceDf.parse(date));
|
||||||
|
} catch (ParseException e) {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue