-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #996 from TeamNewPipe/feat/peeertube-playlists
[PeerTube] Support searching for playlists and channels
- Loading branch information
Showing
7 changed files
with
175 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...habi/newpipe/extractor/services/peertube/extractors/PeertubeChannelInfoItemExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.schabi.newpipe.extractor.services.peertube.extractors; | ||
|
||
import com.grack.nanojson.JsonObject; | ||
import org.schabi.newpipe.extractor.channel.ChannelExtractor; | ||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor; | ||
import org.schabi.newpipe.extractor.exceptions.ParsingException; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Comparator; | ||
|
||
public class PeertubeChannelInfoItemExtractor implements ChannelInfoItemExtractor { | ||
|
||
final JsonObject item; | ||
final JsonObject uploader; | ||
final String baseUrl; | ||
public PeertubeChannelInfoItemExtractor(@Nonnull final JsonObject item, | ||
@Nonnull final String baseUrl) { | ||
this.item = item; | ||
this.uploader = item.getObject("uploader"); | ||
this.baseUrl = baseUrl; | ||
} | ||
|
||
@Override | ||
public String getName() throws ParsingException { | ||
return item.getString("displayName"); | ||
} | ||
|
||
@Override | ||
public String getUrl() throws ParsingException { | ||
return item.getString("url"); | ||
} | ||
|
||
@Override | ||
public String getThumbnailUrl() throws ParsingException { | ||
return item.getArray("avatars").stream() | ||
.filter(JsonObject.class::isInstance) | ||
.map(JsonObject.class::cast) | ||
.max(Comparator.comparingInt(avatar -> avatar.getInt("width"))) | ||
.map(avatar -> baseUrl + avatar.getString("path")) | ||
.orElse(null); | ||
} | ||
|
||
@Override | ||
public String getDescription() throws ParsingException { | ||
return item.getString("description"); | ||
} | ||
|
||
@Override | ||
public long getSubscriberCount() throws ParsingException { | ||
return item.getInt("followersCount"); | ||
} | ||
|
||
@Override | ||
public long getStreamCount() throws ParsingException { | ||
return ChannelExtractor.ITEM_COUNT_UNKNOWN; | ||
} | ||
|
||
@Override | ||
public boolean isVerified() throws ParsingException { | ||
return false; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...abi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistInfoItemExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.schabi.newpipe.extractor.services.peertube.extractors; | ||
|
||
import com.grack.nanojson.JsonObject; | ||
|
||
import org.schabi.newpipe.extractor.exceptions.ParsingException; | ||
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public class PeertubePlaylistInfoItemExtractor implements PlaylistInfoItemExtractor { | ||
|
||
final JsonObject item; | ||
final JsonObject uploader; | ||
final String baseUrl; | ||
|
||
public PeertubePlaylistInfoItemExtractor(@Nonnull final JsonObject item, | ||
@Nonnull final String baseUrl) { | ||
this.item = item; | ||
this.uploader = item.getObject("uploader"); | ||
this.baseUrl = baseUrl; | ||
} | ||
|
||
@Override | ||
public String getName() throws ParsingException { | ||
return item.getString("displayName"); | ||
} | ||
|
||
@Override | ||
public String getUrl() throws ParsingException { | ||
return item.getString("url"); | ||
} | ||
|
||
@Override | ||
public String getThumbnailUrl() throws ParsingException { | ||
return baseUrl + item.getString("thumbnailPath"); | ||
} | ||
|
||
@Override | ||
public String getUploaderName() throws ParsingException { | ||
return uploader.getString("displayName"); | ||
} | ||
|
||
@Override | ||
public String getUploaderUrl() throws ParsingException { | ||
return uploader.getString("url"); | ||
} | ||
|
||
@Override | ||
public boolean isUploaderVerified() throws ParsingException { | ||
return false; | ||
} | ||
|
||
@Override | ||
public long getStreamCount() throws ParsingException { | ||
return item.getInt("videosLength"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters