MP3-Downloader

Kotlin Android

Youtube to MP3 Coverter app

πŸ“· Previews

Download apk

Demo video πŸ“Ή

πŸ›  Tech Stacks & Open Source Libraries

  • Jetpack Compose
  • ViewModel
  • Hilt
  • Moshi
  • Chaquopy : To create an environment to run .py script
  • mobile-ffmpeg : To convert .m4a to mp3
  • yt-dlp : To download .m4a audio from youtube

⭐ Key features

  • Grabbing & Downloading : Chaquopy used to create an environment for running main.py. It contains get_video_info() to grab video info and download_audio() to download m4a audio. During download, it also returns invokes a callback to log progress on Android side.
  • Converting Ffmpeg command to convert file
ffmpeg -i $inputFile -c:v copy -c:a libmp3lame -q:a 4 $outputFile
  • Saving: Input and output streams used

πŸ€” Key challenges faced

  • UI related ❓ Creating multiple screens vs single screen ❓ Architecturing the UI for different steps πŸ’ͺ Solution: Broke down the UI into state machine. During a session, the app is always in one of the following HomeScreenStep

  • yt-dlp related ❓ How to use yt-dlp (python) in Android project ❓ Understanding yt-dlp and creating script for it ❓ How to send progress of download to Android πŸ’ͺ Solution: Used Chaquopy and yt-dlp’s doc

  • ffmpeg related ❓ How to use ffmpeg in Android project ❓ Ffmpeg command to convert file πŸ’ͺ Solution: Used mobile-ffmpeg and ffmpeg’s doc

⭐ Possible Improvements

  • Could have added tests
  • Could have polished the UI

File structure

Click me

MP3 Downloader
β”‚   AndroidManifest.xml
β”‚
β”œβ”€β”€β”€java
β”‚   └───com
β”‚       └───example
β”‚           └───mp3downloader
β”‚               β”‚   App.kt
β”‚               β”‚   MainActivity.kt
β”‚               β”‚
β”‚               β”œβ”€β”€β”€data
β”‚               β”‚   └───model
β”‚               β”‚           DownloadProgressInfo.kt
β”‚               β”‚           VideoInfo.kt
β”‚               β”‚
β”‚               β”œβ”€β”€β”€di
β”‚               β”‚       AppModule.kt
β”‚               β”‚
β”‚               β”œβ”€β”€β”€presentation
β”‚               β”‚   β”œβ”€β”€β”€common
β”‚               β”‚   β”‚   β”‚   DestinationFolderItem.kt
β”‚               β”‚   β”‚   β”‚   DownloadButton.kt
β”‚               β”‚   β”‚   β”‚   ScreenHeader.kt
β”‚               β”‚   β”‚   β”‚   TextFieldItem.kt
β”‚               β”‚   β”‚   β”‚   VideoInfoItem.kt
β”‚               β”‚   β”‚   β”‚
β”‚               β”‚   β”‚   └───step_content
β”‚               β”‚   β”‚           ConvertingStepContent.kt
β”‚               β”‚   β”‚           DownloadingStepContent.kt
β”‚               β”‚   β”‚           FailureStepContent.kt
β”‚               β”‚   β”‚           SavingStepContent.kt
β”‚               β”‚   β”‚           SuccessStepContent.kt
β”‚               β”‚   β”‚
β”‚               β”‚   └───home_screen
β”‚               β”‚           HomeScreen.kt
β”‚               β”‚           HomeScreenEvents.kt
β”‚               β”‚           HomeScreenState.kt
β”‚               β”‚           HomeViewModel.kt
β”‚               β”‚
β”‚               └───ui
β”‚                   └───theme
β”‚                           Color.kt
β”‚                           Theme.kt
β”‚                           Type.kt
β”‚
β”œβ”€β”€β”€python
β”‚       main.py
β”‚
└───res
  β”œβ”€β”€β”€drawable
  β”‚       ic_launcher_background.xml
  β”‚       yt_logo.png
  β”‚
  β”œβ”€β”€β”€drawable-v24
  β”‚       ic_launcher_foreground.xml
  β”‚
  β”œβ”€β”€β”€font
  β”‚       plus_jakarta_sans_bold.ttf
  β”‚       plus_jakarta_sans_semibold.ttf
  β”‚
  β”œβ”€β”€β”€mipmap-anydpi-v26
  β”‚       ic_launcher.xml
  β”‚       ic_launcher_round.xml
  β”‚
  β”œβ”€β”€β”€mipmap-hdpi
  β”‚       ic_launcher.webp
  β”‚       ic_launcher_round.webp
  β”‚
  β”œβ”€β”€β”€mipmap-mdpi
  β”‚       ic_launcher.webp
  β”‚       ic_launcher_round.webp
  β”‚
  β”œβ”€β”€β”€mipmap-xhdpi
  β”‚       ic_launcher.webp
  β”‚       ic_launcher_round.webp
  β”‚
  β”œβ”€β”€β”€mipmap-xxhdpi
  β”‚       ic_launcher.webp
  β”‚       ic_launcher_round.webp
  β”‚
  β”œβ”€β”€β”€mipmap-xxxhdpi
  β”‚       ic_launcher.webp
  β”‚       ic_launcher_round.webp
  β”‚
  β”œβ”€β”€β”€values
  β”‚       colors.xml
  β”‚       strings.xml
  β”‚       themes.xml
  β”‚
  └───xml
          backup_rules.xml
          data_extraction_rules.xml

GitHub

View Github