Skip to content

Commit 68b4c9a

Browse files
authored
Merge pull request #1338 from Stypox/lockup-podcast
[YouTube] Support LOCKUP_CONTENT_TYPE_PODCAST
2 parents a9a4181 + 35cc5a7 commit 68b4c9a

3 files changed

Lines changed: 39 additions & 4 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabExtractor.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,14 @@ private Optional<JsonObject> collectItem(@Nonnull final MultiInfoItemsCollector
313313
.getArray("items"), channelVerifiedStatus, channelName, channelUrl);
314314
} else if (item.has("lockupViewModel")) {
315315
final JsonObject lockupViewModel = item.getObject("lockupViewModel");
316-
if ("LOCKUP_CONTENT_TYPE_PLAYLIST".equals(lockupViewModel.getString("contentType"))) {
316+
final String contentType = lockupViewModel.getString("contentType");
317+
if ("LOCKUP_CONTENT_TYPE_PLAYLIST".equals(contentType)
318+
|| "LOCKUP_CONTENT_TYPE_PODCAST".equals(contentType)) {
317319
commitPlaylistLockup(collector, lockupViewModel, channelVerifiedStatus,
318320
channelName, channelUrl);
321+
} else if ("LOCKUP_CONTENT_TYPE_VIDEO".equals(contentType)) {
322+
commitVideoLockup(collector, timeAgoParser, lockupViewModel, channelVerifiedStatus,
323+
channelName, channelUrl);
319324
}
320325
} else if (item.has("continuationItemRenderer")) {
321326
return Optional.ofNullable(item.getObject("continuationItemRenderer"));
@@ -372,6 +377,31 @@ public boolean isUploaderVerified() {
372377
});
373378
}
374379

380+
private static void commitVideoLockup(@Nonnull final MultiInfoItemsCollector collector,
381+
@Nonnull final TimeAgoParser timeAgoParser,
382+
@Nonnull final JsonObject lockupViewModel,
383+
@Nonnull final VerifiedStatus channelVerifiedStatus,
384+
@Nullable final String channelName,
385+
@Nullable final String channelUrl) {
386+
collector.commit(
387+
new YoutubeStreamInfoItemLockupExtractor(lockupViewModel, timeAgoParser) {
388+
@Override
389+
public String getUploaderName() throws ParsingException {
390+
return isNullOrEmpty(channelName) ? super.getUploaderName() : channelName;
391+
}
392+
393+
@Override
394+
public String getUploaderUrl() throws ParsingException {
395+
return isNullOrEmpty(channelUrl) ? super.getUploaderName() : channelUrl;
396+
}
397+
398+
@Override
399+
public boolean isUploaderVerified() {
400+
return channelVerifiedStatus == VerifiedStatus.VERIFIED;
401+
}
402+
});
403+
}
404+
375405
private void commitPlaylistLockup(@Nonnull final MultiInfoItemsCollector collector,
376406
@Nonnull final JsonObject playlistLockupViewModel,
377407
@Nonnull final VerifiedStatus channelVerifiedStatus,

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,14 @@ private void collectStreamsFrom(final MultiInfoItemsCollector collector,
247247
item.getObject("showRenderer")));
248248
} else if (item.has("lockupViewModel")) {
249249
final JsonObject lockupViewModel = item.getObject("lockupViewModel");
250-
if ("LOCKUP_CONTENT_TYPE_PLAYLIST".equals(
251-
lockupViewModel.getString("contentType"))) {
250+
final String contentType = lockupViewModel.getString("contentType");
251+
if ("LOCKUP_CONTENT_TYPE_PLAYLIST".equals(contentType)
252+
|| "LOCKUP_CONTENT_TYPE_PODCAST".equals(contentType)) {
252253
collector.commit(
253254
new YoutubeMixOrPlaylistLockupInfoItemExtractor(lockupViewModel));
255+
} else if ("LOCKUP_CONTENT_TYPE_VIDEO".equals(contentType)) {
256+
collector.commit(new YoutubeStreamInfoItemLockupExtractor(
257+
lockupViewModel, timeAgoParser));
254258
}
255259
}
256260
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,8 @@ public MultiInfoItemsCollector getRelatedItems() throws ExtractionException {
760760
} else if (result.has("lockupViewModel")) {
761761
final JsonObject lockupViewModel = result.getObject("lockupViewModel");
762762
final String contentType = lockupViewModel.getString("contentType");
763-
if ("LOCKUP_CONTENT_TYPE_PLAYLIST".equals(contentType)) {
763+
if ("LOCKUP_CONTENT_TYPE_PLAYLIST".equals(contentType)
764+
|| "LOCKUP_CONTENT_TYPE_PODCAST".equals(contentType)) {
764765
return new YoutubeMixOrPlaylistLockupInfoItemExtractor(
765766
lockupViewModel);
766767
} else if ("LOCKUP_CONTENT_TYPE_VIDEO".equals(contentType)) {

0 commit comments

Comments
 (0)