Skip to content

Commit

Permalink
refactor: skip parsing using metaphony if failed
Browse files Browse the repository at this point in the history
  • Loading branch information
zyrouge committed Nov 3, 2024
1 parent 7c71491 commit 4a25cc8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MainActivity : ComponentActivity() {
}

Thread.setDefaultUncaughtExceptionHandler { _, err ->
Logger.error("MainActivity", "Uncaught exception", err)
Logger.error("MainActivity", "uncaught exception", err)
ErrorActivity.start(this, err)
finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.github.zyrouge.metaphony.AudioArtwork
import io.github.zyrouge.metaphony.AudioParser
import io.github.zyrouge.symphony.Symphony
import io.github.zyrouge.symphony.utils.DocumentFileX
import io.github.zyrouge.symphony.utils.Logger
import io.github.zyrouge.symphony.utils.SimplePath
import java.io.FileOutputStream
import java.math.RoundingMode
Expand Down Expand Up @@ -96,9 +97,17 @@ data class Song(
}

companion object {
fun parse(symphony: Symphony, path: SimplePath, file: DocumentFileX) =
parseUsingMetaphony(symphony, path, file)
?: parseUsingMediaMetadataRetriever(symphony, path, file)
fun parse(symphony: Symphony, path: SimplePath, file: DocumentFileX): Song {
try {
val song = parseUsingMetaphony(symphony, path, file)
if (song != null) {
return song
}
} catch (err: Exception) {
Logger.error("Song", "could not parse using metaphony", err)
}
return parseUsingMediaMetadataRetriever(symphony, path, file)
}

private fun parseUsingMetaphony(
symphony: Symphony,
Expand Down

0 comments on commit 4a25cc8

Please sign in to comment.