|
1 | 1 | package org.schabi.newpipe.extractor.services.media_ccc.extractors; |
2 | 2 |
|
3 | 3 | import com.grack.nanojson.JsonObject; |
| 4 | + |
| 5 | +import org.schabi.newpipe.extractor.ServiceList; |
| 6 | +import org.schabi.newpipe.extractor.channel.ChannelExtractor; |
| 7 | +import org.schabi.newpipe.extractor.exceptions.ExtractionException; |
4 | 8 | import org.schabi.newpipe.extractor.exceptions.ParsingException; |
5 | 9 | import org.schabi.newpipe.extractor.localization.DateWrapper; |
6 | 10 | import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory; |
7 | 11 | import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor; |
8 | 12 | import org.schabi.newpipe.extractor.stream.StreamType; |
9 | 13 |
|
10 | | -import javax.annotation.Nullable; |
| 14 | +import java.io.IOException; |
11 | 15 | import java.time.ZonedDateTime; |
12 | 16 | import java.time.format.DateTimeFormatter; |
| 17 | +import java.util.Map; |
| 18 | + |
| 19 | +import javax.annotation.Nullable; |
| 20 | + |
| 21 | +import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty; |
13 | 22 |
|
14 | 23 | public class MediaCCCRecentKioskExtractor implements StreamInfoItemExtractor { |
15 | 24 |
|
16 | 25 | private final JsonObject event; |
| 26 | + private final Map<String, String> conferenceNames; |
17 | 27 |
|
18 | | - public MediaCCCRecentKioskExtractor(final JsonObject event) { |
| 28 | + public MediaCCCRecentKioskExtractor(final JsonObject event, |
| 29 | + final Map<String, String> conferenceNames) { |
19 | 30 | this.event = event; |
| 31 | + this.conferenceNames = conferenceNames; |
20 | 32 | } |
21 | 33 |
|
22 | 34 | @Override |
@@ -56,7 +68,25 @@ public long getViewCount() throws ParsingException { |
56 | 68 |
|
57 | 69 | @Override |
58 | 70 | public String getUploaderName() throws ParsingException { |
59 | | - return ""; |
| 71 | + final String conferenceApiUrl = event.getString("conference_url"); |
| 72 | + if (isNullOrEmpty(conferenceApiUrl)) { |
| 73 | + throw new ParsingException("conference url is empty"); |
| 74 | + } |
| 75 | + |
| 76 | + if (conferenceNames.containsKey(conferenceApiUrl)) { |
| 77 | + return conferenceNames.get(conferenceApiUrl); |
| 78 | + } |
| 79 | + |
| 80 | + // get conference name from API. |
| 81 | + try { |
| 82 | + ChannelExtractor extractor = ServiceList.MediaCCC.getChannelExtractor( |
| 83 | + new MediaCCCConferenceLinkHandlerFactory().fromUrl(conferenceApiUrl)); |
| 84 | + extractor.fetchPage(); |
| 85 | + conferenceNames.put(conferenceApiUrl, extractor.getName()); |
| 86 | + return extractor.getName(); |
| 87 | + } catch (IOException | ExtractionException e) { |
| 88 | + throw new ParsingException("Could not get conference name from conference API URL", e); |
| 89 | + } |
60 | 90 | } |
61 | 91 |
|
62 | 92 | @Override |
|
0 commit comments