Merge pull request #321 from TeamPiped/disable-lbry

Add option to disable LBRY.
This commit is contained in:
Kavin 2022-07-22 09:26:58 +05:30 committed by GitHub
commit a9295f82b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View File

@ -27,6 +27,8 @@ RYD_PROXY_URL:https://ryd-proxy.kavin.rocks
DISABLE_RYD:false
# Disable API server (node just runs timers if enabled)
DISABLE_SERVER:false
# Disable the inclusion of LBRY streams
DISABLE_LBRY:false
# Hibernate properties
hibernate.connection.url:jdbc:postgresql://postgres:5432/piped
hibernate.connection.driver_class:org.postgresql.Driver

View File

@ -57,6 +57,8 @@ public class Constants {
public static final boolean DISABLE_SERVER;
public static final boolean DISABLE_LBRY;
public static final String VERSION;
public static final ObjectMapper mapper = new ObjectMapper().addMixIn(Page.class, PageMixin.class);
@ -87,6 +89,7 @@ public class Constants {
RYD_PROXY_URL = getProperty(prop, "RYD_PROXY_URL", "https://ryd-proxy.kavin.rocks");
DISABLE_RYD = Boolean.parseBoolean(getProperty(prop, "DISABLE_RYD", "false"));
DISABLE_SERVER = Boolean.parseBoolean(getProperty(prop, "DISABLE_SERVER", "false"));
DISABLE_LBRY = Boolean.parseBoolean(getProperty(prop, "DISABLE_LBRY", "false"));
System.getenv().forEach((key, value) -> {
if (key.startsWith("hibernate"))
hibernateProperties.put(key, value);

View File

@ -12,6 +12,10 @@ import java.io.IOException;
public class LbryHelper {
public static String getLBRYId(String videoId) throws IOException {
if (Constants.DISABLE_LBRY)
return null;
return new JSONObject(
RequestUtils.sendGet("https://api.lbry.com/yt/resolve?video_ids=" + URLUtils.silentEncode(videoId))
).getJSONObject("data").getJSONObject("videos").optString(videoId, null);