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_RYD:false
# Disable API server (node just runs timers if enabled) # Disable API server (node just runs timers if enabled)
DISABLE_SERVER:false DISABLE_SERVER:false
# Disable the inclusion of LBRY streams
DISABLE_LBRY:false
# Hibernate properties # Hibernate properties
hibernate.connection.url:jdbc:postgresql://postgres:5432/piped hibernate.connection.url:jdbc:postgresql://postgres:5432/piped
hibernate.connection.driver_class:org.postgresql.Driver 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_SERVER;
public static final boolean DISABLE_LBRY;
public static final String VERSION; public static final String VERSION;
public static final ObjectMapper mapper = new ObjectMapper().addMixIn(Page.class, PageMixin.class); 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"); RYD_PROXY_URL = getProperty(prop, "RYD_PROXY_URL", "https://ryd-proxy.kavin.rocks");
DISABLE_RYD = Boolean.parseBoolean(getProperty(prop, "DISABLE_RYD", "false")); DISABLE_RYD = Boolean.parseBoolean(getProperty(prop, "DISABLE_RYD", "false"));
DISABLE_SERVER = Boolean.parseBoolean(getProperty(prop, "DISABLE_SERVER", "false")); DISABLE_SERVER = Boolean.parseBoolean(getProperty(prop, "DISABLE_SERVER", "false"));
DISABLE_LBRY = Boolean.parseBoolean(getProperty(prop, "DISABLE_LBRY", "false"));
System.getenv().forEach((key, value) -> { System.getenv().forEach((key, value) -> {
if (key.startsWith("hibernate")) if (key.startsWith("hibernate"))
hibernateProperties.put(key, value); hibernateProperties.put(key, value);

View file

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