Merge pull request #472 from TeamPiped/countries-frontend

Add supported countries to frontend properties.
This commit is contained in:
Kavin 2022-11-26 19:24:39 +00:00 committed by GitHub
commit 6c4b771a80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ package me.kavin.piped.consts;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import me.kavin.piped.utils.PageMixin;
@ -14,6 +15,7 @@ import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.localization.ContentCountry;
import java.io.File;
import java.io.FileReader;
@ -136,6 +138,10 @@ public class Constants {
frontendProperties.put(StringUtils.substringAfter(key, "frontend."), value);
});
frontendProperties.put("imageProxyUrl", IMAGE_PROXY_PART);
frontendProperties.putArray("countries").addAll(
YOUTUBE_SERVICE.getSupportedCountries().stream().map(ContentCountry::getCountryCode)
.map(JsonNodeFactory.instance::textNode).toList()
);
// transform hibernate properties for legacy configurations
hibernateProperties.replace("hibernate.dialect",