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

fix youtube / vimeo error



Signed-off-by: Sebastian Schüpbach's avatarSebastian Schüpbach <sebastian.schuepbach@unibas.ch>
parent e0302c78
Pipeline #16549 passed with stages
in 6 minutes and 5 seconds
......@@ -136,7 +136,11 @@ class KafkaTopology(private val settings: SettingsLoader) {
}?.let {
val pathOnSftpServer = previewImageHandler.moveFileToSFTP(
it,
"$sftpBasePath/${value.first.second.recordSetId}/${Constant.thumbnailFolderName}/$value.jpg"
"$sftpBasePath/${value.first.second.recordSetId}/${Constant.thumbnailFolderName}/${
record.uri.split(
"/"
).last()
}.jpg"
)
if (pathOnSftpServer != null) {
createThumbnailResource(value.first.first, record, digitalObject, pathOnSftpServer)
......@@ -265,12 +269,13 @@ class KafkaTopology(private val settings: SettingsLoader) {
)
}
}
// No file found in indicated directory
Triple(
data.first,
data.second,
Report(
record.uri,
ReportStatus.failure,
if (type == "thumbnails") ReportStatus.success else ReportStatus.failure,
"${data.third.message}\n${ReportMessages.reportFailure(digitalObject.uri, type)}".trim()
)
)
......
......@@ -8,6 +8,7 @@ import java.net.URL
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
/**
......@@ -20,7 +21,7 @@ class PreviewImageHandler(private val sftpClient: SftpClient) {
/**
* Checks if URL points to Vimeo
*
* @param URL to be scrutinised
* @param url to be scrutinised
*
* @return true if URL points to Vimeo
*/
......@@ -70,11 +71,16 @@ class PreviewImageHandler(private val sftpClient: SftpClient) {
* @return Path to local file
*/
fun getFromYoutube(videoURL: String): String? {
val id = URL(videoURL).query.split("&").firstOrNull {
it.startsWith("v=")
val url = URL(videoURL)
val id = if (url.host.endsWith("youtube.com")) {
URL(videoURL).query.split("&").firstOrNull {
it.startsWith("v=")
}?.substring(2)
} else {
url.path.substring(1)
}
return if (id != null) {
get("https://img.youtube.com/vi/${id.substring(2)}/hqdefault.jpg")
get("https://img.youtube.com/vi/$id/hqdefault.jpg")
} else {
null
}
......@@ -105,7 +111,10 @@ class PreviewImageHandler(private val sftpClient: SftpClient) {
Files.delete(Paths.get(sourcePath))
destPath
} catch (ex: IOException) {
log.warn("Moving thumbnail file to sFTP server failed: ${ex.message}")
log.warn("Moving thumbnail file to sFTP server on directory $destPath failed: ${ex.message}")
null
} catch (ex: SftpClientException) {
log.warn("Moving thumbnail file to sFTP server on directory $destPath failed: ${ex.message}")
null
}
}
......
......@@ -162,7 +162,7 @@ class TestKafkaTopology {
}
private fun testParams() = Stream.of(
/*TestParams(
TestParams(
1,
"test1.yml",
"https://memobase.ch/record/test-institution-id-MEI_49884",
......@@ -179,12 +179,12 @@ class TestKafkaTopology {
"test1.yml",
"https://memobase.ch/record/Tanzarchiv-42858-43349",
"https://memobase.ch/record/Tanzarchiv-42858-43349"
),*/
TestParams(
)
/*TestParams(
5,
"test1.yml",
"https://memobase.ch/record/Tanzarchiv-42858-43349",
"https://memobase.ch/record/Tanzarchiv-42858-43349"
)
)*/
)
}
{
"id": "https://memobase.ch/record/Tanzarchiv-42858-43349",
"status": "FAILURE",
"status": "SUCCESS",
"message": "No valid file found for id https://memobase.ch/digital/Tanzarchiv-42858-43349-1 in folder thumbnails."
}
\ No newline at end of file
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived> <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#locator> "/base/test-record-set-id/thumbnails/Tanzarchiv-42858-43349.jpg" .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.ica.org/standards/RiC/ontology#Instantiation> .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived> <https://www.ica.org/standards/RiC/ontology#instantiates> <https://memobase.ch/record/Tanzarchiv-42858-43349> .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived> <https://www.ica.org/standards/RiC/ontology#isDerivedFromInstantiation> <https://memobase.ch/digital/Tanzarchiv-42858-43349-1> .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived> <https://www.ica.org/standards/RiC/ontology#type> "thumbnail" .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1> <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#locator> "https://vimeo.com/199629565" .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.ica.org/standards/RiC/ontology#Instantiation> .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1> <https://www.ica.org/standards/RiC/ontology#hasDerivedInstantiation> <https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived> .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1> <https://www.ica.org/standards/RiC/ontology#identifiedBy> _:B .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1> <https://www.ica.org/standards/RiC/ontology#instantiates> <https://memobase.ch/record/Tanzarchiv-42858-43349> .
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1> <https://www.ica.org/standards/RiC/ontology#isDerivedFromInstantiation> <https://memobase.ch/physical/Tanzarchiv-42858-43349-1> .
......@@ -23,6 +29,7 @@
<https://memobase.ch/record/Tanzarchiv-42858-43349> <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#hasGenre> _:B .
<https://memobase.ch/record/Tanzarchiv-42858-43349> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.ica.org/standards/RiC/ontology#Record> .
<https://memobase.ch/record/Tanzarchiv-42858-43349> <https://www.ica.org/standards/RiC/ontology#conditionsOfUse> "Das Schweizer Tanzarchiv verfügt über das Recht, die Dokumente zu archivieren und sie den Nutzenden online und vor Ort zur Verfügung zu stellen. Zum Zweck der Lehre und Forschung können die Dokumente ausgeliehen werden. Jede anderweitige Nutzung ausserhalb des Archivs (für Vervielfältigungen, Publikationen oder Veranstaltungen) muss individuell mit den Rechteinhabern geklärt werden." .
<https://memobase.ch/record/Tanzarchiv-42858-43349> <https://www.ica.org/standards/RiC/ontology#hasInstantiation> <https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived> .
<https://memobase.ch/record/Tanzarchiv-42858-43349> <https://www.ica.org/standards/RiC/ontology#hasInstantiation> <https://memobase.ch/digital/Tanzarchiv-42858-43349-1> .
<https://memobase.ch/record/Tanzarchiv-42858-43349> <https://www.ica.org/standards/RiC/ontology#hasInstantiation> <https://memobase.ch/physical/Tanzarchiv-42858-43349-1> .
<https://memobase.ch/record/Tanzarchiv-42858-43349> <https://www.ica.org/standards/RiC/ontology#hasSubject> _:B .
......
{
"id": "https://memobase.ch/record/Tanzarchiv-42858-43349",
"status": "FAILURE",
"status": "SUCCESS",
"message": "No valid file found for id https://memobase.ch/digital/Tanzarchiv-42858-43349-1 in folder thumbnails."
}
\ No newline at end of file
@prefix schema: <http://schema.org/> .
@prefix internal: <http://memobase.ch/internal/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix mbrs: <https://memobase.ch/recordSet/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix wdt: <http://www.wikidata.org/prop/direct/> .
@prefix mbcb: <https://memobase.ch/institution/> .
@prefix mbpo: <https://memobase.ch/physical/> .
@prefix mbcb: <https://memobase.ch/institution/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix wd: <http://www.wikidata.org/entity/> .
@prefix wdtn: <http://www.wikidata.org/prop/direct-normalized/> .
@prefix rdau: <http://rdaregistry.info/Elements/u/> .
@prefix mbdo: <https://memobase.ch/digital/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdau: <http://rdaregistry.info/Elements/u/> .
@prefix fedora: <http://fedora.info/definitions/v4/repository#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rico: <https://www.ica.org/standards/RiC/ontology#> .
@prefix ebucore: <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix mbr: <https://memobase.ch/record/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
......
@prefix schema: <http://schema.org/> .
@prefix internal: <http://memobase.ch/internal/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix mbrs: <https://memobase.ch/recordSet/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix wdt: <http://www.wikidata.org/prop/direct/> .
@prefix mbcb: <https://memobase.ch/institution/> .
@prefix mbpo: <https://memobase.ch/physical/> .
@prefix mbcb: <https://memobase.ch/institution/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix wd: <http://www.wikidata.org/entity/> .
@prefix wdtn: <http://www.wikidata.org/prop/direct-normalized/> .
@prefix rdau: <http://rdaregistry.info/Elements/u/> .
@prefix mbdo: <https://memobase.ch/digital/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdau: <http://rdaregistry.info/Elements/u/> .
@prefix fedora: <http://fedora.info/definitions/v4/repository#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rico: <https://www.ica.org/standards/RiC/ontology#> .
@prefix ebucore: <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix mbr: <https://memobase.ch/record/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
......
@prefix schema: <http://schema.org/> .
@prefix internal: <http://memobase.ch/internal/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix mbrs: <https://memobase.ch/recordSet/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix wdt: <http://www.wikidata.org/prop/direct/> .
@prefix mbcb: <https://memobase.ch/institution/> .
@prefix mbpo: <https://memobase.ch/physical/> .
@prefix mbcb: <https://memobase.ch/institution/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix wd: <http://www.wikidata.org/entity/> .
@prefix wdtn: <http://www.wikidata.org/prop/direct-normalized/> .
@prefix rdau: <http://rdaregistry.info/Elements/u/> .
@prefix mbdo: <https://memobase.ch/digital/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdau: <http://rdaregistry.info/Elements/u/> .
@prefix fedora: <http://fedora.info/definitions/v4/repository#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rico: <https://www.ica.org/standards/RiC/ontology#> .
@prefix ebucore: <http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix mbr: <https://memobase.ch/record/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
......@@ -35,7 +35,7 @@ mbr:Tanzarchiv-42858-43349
skos:prefLabel "Stückaufzeichnung"
] ;
rico:conditionsOfUse "Das Schweizer Tanzarchiv verfügt über das Recht, die Dokumente zu archivieren und sie den Nutzenden online und vor Ort zur Verfügung zu stellen. Zum Zweck der Lehre und Forschung können die Dokumente ausgeliehen werden. Jede anderweitige Nutzung ausserhalb des Archivs (für Vervielfältigungen, Publikationen oder Veranstaltungen) muss individuell mit den Rechteinhabern geklärt werden." ;
rico:hasInstantiation mbpo:Tanzarchiv-42858-43349-1 , mbdo:Tanzarchiv-42858-43349-1 ;
rico:hasInstantiation mbpo:Tanzarchiv-42858-43349-1 , mbdo:Tanzarchiv-42858-43349-1 , <https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived> ;
rico:hasSubject [ a skos:Concept ;
skos:prefLabel "Schweiz, zeitgenössischer Tanz"
] ;
......@@ -45,16 +45,16 @@ mbr:Tanzarchiv-42858-43349
] ;
rico:heldBy mbcb:Tanzarchiv ;
rico:identifiedBy [ a rico:Identifier ;
rico:identifier "Tanzarchiv-42858-43349" ;
rico:type "main"
rico:identifier "43349" ;
rico:type "original"
] ;
rico:identifiedBy [ a rico:Identifier ;
rico:identifier "Tanzarchiv-43349" ;
rico:type "oldMemobase"
] ;
rico:identifiedBy [ a rico:Identifier ;
rico:identifier "43349" ;
rico:type "original"
rico:identifier "Tanzarchiv-42858-43349" ;
rico:type "main"
] ;
rico:isPartOf mbrs:Tanzarchiv-42858 ;
rico:recordResourceOrInstantiationIsSourceOfCreationRelation
......@@ -68,37 +68,38 @@ mbr:Tanzarchiv-42858-43349
rico:title "Additional Tones" ;
rico:type "Video" .
_:b0 a rico:CreationRelation ;
rico:creationRelationHasSource mbr:Tanzarchiv-42858-43349 ;
rico:creationRelationHasTarget [ a rico:CorporateBody ;
rico:agentIsTargetOfCreationRelation
_:b0 ;
rico:name "Compagnie Linga"
] ;
rico:name "Kompanie / Compagnie" ;
rico:type "contributor" .
_:b2 a rico:CreationRelation ;
rico:creationRelationHasSource mbr:Tanzarchiv-42858-43349 ;
rico:creationRelationHasTarget [ a rico:Person ;
rico:agentIsTargetOfCreationRelation
_:b2 ;
rico:name "Katarzyna Gdaniec (Choreograf / Chorégraphe)"
rico:name "Christophe Calpini"
] ;
rico:name "Author" ;
rico:type "creator" .
rico:name "Komponisten / Compositeur" ;
rico:type "contributor" .
mbdo:Tanzarchiv-42858-43349-1
a rico:Instantiation ;
ebucore:locator "https://vimeo.com/199629565" ;
rico:identifiedBy [ a rico:Identifier ;
rico:identifier "Tanzarchiv-42858-43349-1" ;
rico:type "main"
] ;
rico:instantiates mbr:Tanzarchiv-42858-43349 ;
a rico:Instantiation ;
ebucore:locator "https://vimeo.com/199629565" ;
rico:hasDerivedInstantiation <https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived> ;
rico:identifiedBy [ a rico:Identifier ;
rico:identifier "Tanzarchiv-42858-43349-1" ;
rico:type "main"
] ;
rico:instantiates mbr:Tanzarchiv-42858-43349 ;
rico:isDerivedFromInstantiation
mbpo:Tanzarchiv-42858-43349-1 ;
rico:type "digitalObject" .
_:b1 a rico:CreationRelation ;
rico:creationRelationHasSource mbr:Tanzarchiv-42858-43349 ;
rico:creationRelationHasTarget [ a rico:CorporateBody ;
rico:agentIsTargetOfCreationRelation
_:b1 ;
rico:name "Compagnie Linga"
] ;
rico:name "Kompanie / Compagnie" ;
rico:type "contributor" .
rico:type "digitalObject" .
mbpo:Tanzarchiv-42858-43349-1
a rico:Instantiation ;
......@@ -124,12 +125,20 @@ mbpo:Tanzarchiv-42858-43349-1
] ;
rico:type "physicalObject" .
_:b0 a rico:CreationRelation ;
<https://memobase.ch/digital/Tanzarchiv-42858-43349-1/derived>
a rico:Instantiation ;
ebucore:locator "/base/test-record-set-id/thumbnails/Tanzarchiv-42858-43349.jpg" ;
rico:instantiates mbr:Tanzarchiv-42858-43349 ;
rico:isDerivedFromInstantiation
mbdo:Tanzarchiv-42858-43349-1 ;
rico:type "thumbnail" .
_:b1 a rico:CreationRelation ;
rico:creationRelationHasSource mbr:Tanzarchiv-42858-43349 ;
rico:creationRelationHasTarget [ a rico:Person ;
rico:agentIsTargetOfCreationRelation
_:b0 ;
rico:name "Christophe Calpini"
_:b1 ;
rico:name "Katarzyna Gdaniec (Choreograf / Chorégraphe)"
] ;
rico:name "Komponisten / Compositeur" ;
rico:type "contributor" .
rico:name "Author" ;
rico:type "creator" .
Supports Markdown
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