Skip to content

Commit ed37c07

Browse files
authored
Dailymotion Improvement to Add Subtitles (#1765)
1 parent 8cc9220 commit ed37c07

1 file changed

Lines changed: 30 additions & 9 deletions

File tree

  • library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors

library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Dailymotion.kt

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,28 @@ open class Dailymotion : ExtractorApi() {
4848
getStream(it.url, this.name, callback)
4949
}
5050
}
51+
metaData.subtitles.data.forEach { (_, subtitle) ->
52+
val subUrl = subtitle.urls.firstOrNull() ?: return@forEach
53+
subtitleCallback.invoke(
54+
SubtitleFile(
55+
subtitle.label,
56+
subUrl
57+
)
58+
)
59+
}
60+
5161
}
5262

5363
private fun getEmbedUrl(url: String): String? {
54-
if (url.contains("/embed/") || url.contains("/video/")) {
55-
return url
64+
if (url.contains("/embed/") || url.contains("/video/")) {
65+
return url
66+
}
67+
if (url.contains("geo.dailymotion.com")) {
68+
val videoId = url.substringAfter("video=")
69+
return "$baseUrl/embed/video/$videoId"
70+
}
71+
return null
5672
}
57-
if (url.contains("geo.dailymotion.com")) {
58-
val videoId = url.substringAfter("video=")
59-
return "$baseUrl/embed/video/$videoId"
60-
}
61-
return null
62-
}
6373

6474
private fun getVideoId(url: String): String? {
6575
val path = URI(url).path
@@ -97,7 +107,18 @@ open class Dailymotion : ExtractorApi() {
97107
)
98108

99109
data class MetaData(
100-
val qualities: Map<String, List<VideoLink>>
110+
val qualities: Map<String, List<VideoLink>>,
111+
val subtitles: Subtitles,
112+
)
113+
114+
data class Subtitles(
115+
val enable: Boolean,
116+
val data: Map<String, Subtitle>
117+
)
118+
119+
data class Subtitle(
120+
val label: String,
121+
val urls: List<String>,
101122
)
102123

103124
data class VideoLink(

0 commit comments

Comments
 (0)