Skip to content

Commit 3add704

Browse files
authored
Merge pull request #239 from B0pol/peertube
[PeerTube] added metadata, fix descriptions, fix thumbnail, fix upload date, fix age limit, update tests.
2 parents 62b81c3 + 0e33249 commit 3add704

19 files changed

Lines changed: 566 additions & 144 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ To test changes quickly you can build the library locally. Using the local Maven
2121
2. It's _recommended_ that you change the `version` of this library (e.g. `LOCAL_SNAPSHOT`).
2222
3. Run gradle's `ìnstall` task to deploy this library to your local repository (using the wrapper, present in the root of this project: `./gradlew install`)
2323
4. Change the dependency version used in your project to match the one you chose in step 2 (`implementation 'com.github.TeamNewPipe:NewPipeExtractor:LOCAL_SNAPSHOT'`)
24-
24+
2525
> Tip for Android Studio users: After you make changes and run the `install` task, use the menu option `File → "Sync with File System"` to refresh the library in your project.
2626
2727
## Supported sites

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.io.IOException;
1818
import java.util.ArrayList;
1919
import java.util.List;
20+
import java.util.Locale;
2021

2122
public class MediaCCCStreamExtractor extends StreamExtractor {
2223

@@ -47,8 +48,8 @@ public String getThumbnailUrl() throws ParsingException {
4748

4849
@Nonnull
4950
@Override
50-
public String getDescription() throws ParsingException {
51-
return data.getString("description");
51+
public Description getDescription() throws ParsingException {
52+
return new Description(data.getString("description"), Description.PLAIN_TEXT);
5253
}
5354

5455
@Override
@@ -225,4 +226,41 @@ public String getName() throws ParsingException {
225226
public String getOriginalUrl() throws ParsingException {
226227
return data.getString("frontend_link");
227228
}
229+
230+
@Override
231+
public String getHost() throws ParsingException {
232+
return "";
233+
}
234+
235+
@Override
236+
public String getPrivacy() throws ParsingException {
237+
return "";
238+
}
239+
240+
@Override
241+
public String getCategory() throws ParsingException {
242+
return "";
243+
}
244+
245+
@Override
246+
public String getLicence() throws ParsingException {
247+
return "";
248+
}
249+
250+
@Override
251+
public Locale getLanguageInfo() throws ParsingException {
252+
return null;
253+
}
254+
255+
@Nonnull
256+
@Override
257+
public List<String> getTags() throws ParsingException {
258+
return new ArrayList<>();
259+
}
260+
261+
@Nonnull
262+
@Override
263+
public String getSupportInfo() throws ParsingException {
264+
return "";
265+
}
228266
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeParsingHelper.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.text.SimpleDateFormat;
55
import java.util.Calendar;
66
import java.util.Date;
7+
import java.util.TimeZone;
78

89
import org.jsoup.helper.StringUtil;
910
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
@@ -12,21 +13,23 @@
1213
import com.grack.nanojson.JsonObject;
1314

1415
public class PeertubeParsingHelper {
15-
16+
1617
private PeertubeParsingHelper() {
1718
}
1819

1920
public static void validate(JsonObject json) throws ContentNotAvailableException {
2021
String error = json.getString("error");
21-
if(!StringUtil.isBlank(error)) {
22+
if (!StringUtil.isBlank(error)) {
2223
throw new ContentNotAvailableException(error);
2324
}
2425
}
25-
26+
2627
public static Calendar parseDateFrom(String textualUploadDate) throws ParsingException {
2728
Date date;
2829
try {
29-
date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'").parse(textualUploadDate);
30+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
31+
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
32+
date = sdf.parse(textualUploadDate);
3033
} catch (ParseException e) {
3134
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e);
3235
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public String getCommentText() throws ParsingException {
6767
try {
6868
Document doc = Jsoup.parse(htmlText);
6969
return doc.body().text();
70-
}catch(Exception e) {
70+
} catch(Exception e) {
7171
return htmlText.replaceAll("(?s)<[^>]*>(\\s*<[^>]*>)*", "");
7272
}
7373
}
@@ -83,15 +83,15 @@ public String getAuthorThumbnail() throws ParsingException {
8383
String value;
8484
try {
8585
value = JsonUtils.getString(item, "account.avatar.path");
86-
}catch(Exception e) {
86+
} catch(Exception e) {
8787
value = "/client/assets/images/default-avatar.png";
8888
}
8989
return baseUrl + value;
9090
}
9191

9292
@Override
9393
public String getAuthorName() throws ParsingException {
94-
return JsonUtils.getString(item, "account.displayName");
94+
return JsonUtils.getString(item, "account.name") + "@" + JsonUtils.getString(item, "account.host");
9595
}
9696

9797
@Override

0 commit comments

Comments
 (0)