Skip to content

Commit b931041

Browse files
committed
*Log4j causing trouble with Android has been fixed
*Added codec based MimeType
1 parent a700f00 commit b931041

8 files changed

Lines changed: 32 additions & 10 deletions

File tree

.idea/artifacts/VidSnapKit_jvm_2_0_2.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ plugins {
1919
kotlin("multiplatform") version "1.7.22"
2020
id("convention.publication")
2121
id("com.android.library")
22+
id("org.jetbrains.kotlin.android") version "1.7.22" apply false
2223
}
2324

2425
group = "io.github.udhayarajan"
25-
version = "2.0.2"
26+
version = "2.0.3"
2627
//Version Naming incremented if "<NEW_FEATURE_ADDED>.<WORKED_ON_BUG>.<BETA_VERSION_COUNT>"
2728

2829
repositories {
@@ -64,14 +65,10 @@ kotlin {
6465
implementation("io.ktor:ktor-client-core:$ktor_version")
6566
implementation("io.ktor:ktor-client-android:$ktor_version")
6667
implementation("io.ktor:ktor-client-serialization:$ktor_version")
67-
implementation("io.ktor:ktor-client-logging:$ktor_version")
6868

6969
// https://mvnrepository.com/artifact/org.json/json
7070
implementation("org.json:json:20220924")
7171

72-
// https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
73-
implementation("org.apache.logging.log4j:log4j-core:2.19.0")
74-
7572
}
7673
}
7774
val commonTest by getting {
@@ -96,4 +93,7 @@ android {
9693
lint {
9794
isAbortOnError = false
9895
}
99-
}
96+
}
97+
dependencies {
98+
implementation("androidx.core:core-ktx:+")
99+
}

src/commonMain/kotlin/com/mugames/vidsnapkit/MimeType.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,15 @@ class MimeType {
6868
* Constant Value: "application/x-mpegURL"
6969
*/
7070
const val APPLICATION_X_MPEG_URL = "application/x-mpegURL";
71+
72+
fun fromCodecs(codec: String) = with(codec) {
73+
when {
74+
contains("mp4a", ignoreCase = true) -> MimeType.AUDIO_MP4
75+
contains("opus", ignoreCase = true) -> MimeType.AUDIO_WEBM
76+
contains("avc", ignoreCase = true) -> MimeType.VIDEO_MP4
77+
contains("vp8", ignoreCase = true) || contains("vp9", ignoreCase = true) -> MimeType.VIDEO_WEBM
78+
else -> throw Exception("Unable to find mimetype from codec $codec")
79+
}
80+
}
7181
}
7282
}

src/commonMain/kotlin/com/mugames/vidsnapkit/dataholders/Resource.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@ data class AudioResource(
5959
val url: String,
6060
val mimeType: String,
6161
var size: Long = 0,
62+
var bitrate: Long? = null
6263
)

src/commonMain/kotlin/com/mugames/vidsnapkit/extractor/Vimeo.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.mugames.vidsnapkit.extractor
1919

20+
import com.mugames.vidsnapkit.MimeType
2021
import com.mugames.vidsnapkit.dataholders.AudioResource
2122
import com.mugames.vidsnapkit.dataholders.Formats
2223
import com.mugames.vidsnapkit.dataholders.ImageResource
@@ -91,7 +92,7 @@ class Vimeo internal constructor(url: String) : Extractor(url) {
9192
fun getUrlAndMimeFromObject(jsonObject: JSONObject) =
9293
listOf(
9394
url + jsonObject.get("base_url") + jsonObject.get("id") + ".mp4",
94-
jsonObject.getString("mime_type")
95+
MimeType.fromCodecs(jsonObject.getString("codecs"))
9596
)
9697

9798
fun extractVideoData() {
@@ -120,7 +121,8 @@ class Vimeo internal constructor(url: String) : Extractor(url) {
120121
formats.audioData.add(
121122
AudioResource(
122123
audioUrl,
123-
mime
124+
mime,
125+
bitrate = it.getLong("bitrate")
124126
)
125127
)
126128
}

0 commit comments

Comments
 (0)