Unverified Commit d4e0fd38 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

use https links for youtube oembed api

parent fc7161a2
Pipeline #20559 passed with stages
in 4 minutes and 2 seconds
......@@ -46,7 +46,7 @@ dependencies {
// JSON Parser
implementation 'com.beust:klaxon:5.2'
implementation 'org.memobase:memobase-service-utilities:1.12.2'
implementation 'org.memobase:memobase-service-utilities:2.0.4'
implementation 'org.apache.jena:apache-jena:3.14.0'
......
......@@ -18,6 +18,13 @@
package org.memobase
import ch.memobase.rdf.EBUCORE
import ch.memobase.rdf.RDF
import ch.memobase.rdf.RICO
import ch.memobase.settings.HeaderExtractionTransformSupplier
import ch.memobase.settings.HeaderMetadata
import ch.memobase.settings.SettingsLoader
import ch.memobase.sftp.SftpClient
import java.io.StringReader
import java.io.StringWriter
import java.net.MalformedURLException
......@@ -31,15 +38,8 @@ import org.apache.kafka.streams.StreamsBuilder
import org.apache.kafka.streams.kstream.KStream
import org.apache.kafka.streams.kstream.Predicate
import org.apache.logging.log4j.LogManager
import org.memobase.rdf.EBUCORE
import org.memobase.rdf.RDF
import org.memobase.rdf.RICO
import org.memobase.reports.ReportMessages
import org.memobase.reports.ReportStatus
import org.memobase.settings.SettingsLoader
import org.memobase.sftp.SftpClient
import settings.HeaderExtractionTransformSupplier
import settings.HeaderMetadata
class KafkaTopology(private val settings: SettingsLoader) {
private val appSettings = settings.appSettings
......
package org.memobase
import ch.memobase.exceptions.SftpClientException
import ch.memobase.sftp.SftpClient
import java.io.ByteArrayOutputStream
import java.io.FileNotFoundException
import java.io.FileOutputStream
......@@ -11,8 +13,6 @@ import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Paths
import org.apache.logging.log4j.LogManager
import org.memobase.exceptions.SftpClientException
import org.memobase.sftp.SftpClient
/**
* Queries oembed API for videos on Vimeo or Youtube and downloads poster images
......@@ -22,6 +22,7 @@ class RemoteResourceHandler(private val sftpClient: SftpClient) {
companion object {
private val log = LogManager.getLogger("MediaLinker")
/**
* Checks if URL points to Vimeo
*
......@@ -54,6 +55,9 @@ class RemoteResourceHandler(private val sftpClient: SftpClient) {
inputStream.copyTo(outputStream)
}
}
} catch (e: IOException) {
log.warn("Got a HTTP exception: ${e.message}")
return null
} catch (e: FileNotFoundException) {
log.warn("Couldn't find oembed object on $urlAsString. Is this resource still available?")
return null
......@@ -64,7 +68,7 @@ class RemoteResourceHandler(private val sftpClient: SftpClient) {
fun getYoutubeOembedObject(url: String): OembedResponse? {
return getOembedObject(
"http://www.youtube.com/oembed?url=${
"https://www.youtube.com/oembed?url=${
URLEncoder.encode(
url,
StandardCharsets.UTF_8.toString()
......
......@@ -17,10 +17,10 @@
*/
package org.memobase
import ch.memobase.settings.SettingsLoader
import kotlin.system.exitProcess
import org.apache.kafka.streams.KafkaStreams
import org.apache.logging.log4j.LogManager
import org.memobase.settings.SettingsLoader
class Service(file: String = "app.yml") {
private val log = LogManager.getLogger("MediaLinkerService")
......
......@@ -17,6 +17,8 @@
*/
package org.memobase
import ch.memobase.rdf.NS
import ch.memobase.testing.EmbeddedSftpServer
import com.beust.klaxon.Klaxon
import java.io.File
import java.io.FileInputStream
......@@ -39,8 +41,6 @@ import org.junit.jupiter.api.TestInstance
import org.junit.jupiter.api.assertAll
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.memobase.rdf.NS
import org.memobase.testing.EmbeddedSftpServer
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TestKafkaTopology {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment