Youtube Music Support and bug fixes.

This commit is contained in:
shabinder 2021-01-08 01:53:32 +05:30
parent 0c0ebded5a
commit 243cdf1a27
8 changed files with 53 additions and 20 deletions

View File

@ -40,8 +40,8 @@ android {
//Some Os's Don't give Access to Music Dir , In API 29 if we Target 30 //Some Os's Don't give Access to Music Dir , In API 29 if we Target 30
//noinspection OldTargetApi //noinspection OldTargetApi
targetSdkVersion 29 targetSdkVersion 29
versionCode 13 versionCode 14
versionName "2.0.1" versionName "2.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }
@ -160,7 +160,7 @@ dependencies {
implementation 'com.razorpay:checkout:1.6.4' implementation 'com.razorpay:checkout:1.6.4'
implementation "com.github.amitbd1508:AppUpdater:4.1.0" implementation "com.github.amitbd1508:AppUpdater:4.1.0"
implementation "androidx.tonyodev.fetch2:xfetch2:3.1.5" implementation "androidx.tonyodev.fetch2:xfetch2:3.1.5"
implementation 'com.github.sealedtx:java-youtube-downloader:2.4.4' implementation 'com.github.sealedtx:java-youtube-downloader:2.4.6'
//Crashlytics & Analytics //Crashlytics & Analytics
implementation platform('com.google.firebase:firebase-bom:26.2.0') implementation platform('com.google.firebase:firebase-bom:26.2.0')

View File

@ -23,6 +23,7 @@
<package android:name="com.gaana" /> <package android:name="com.gaana" />
<package android:name="com.spotify.music" /> <package android:name="com.spotify.music" />
<package android:name="com.google.android.youtube" /> <package android:name="com.google.android.youtube" />
<package android:name="com.google.android.apps.youtube.music" />
</queries> </queries>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>

View File

@ -49,7 +49,6 @@ class SpotifyProvider @Inject constructor(
spotifyLink = resolveLink(spotifyLink) spotifyLink = resolveLink(spotifyLink)
} }
val link = spotifyLink.substringAfterLast('/', "Error").substringBefore('?') val link = spotifyLink.substringAfterLast('/', "Error").substringBefore('?')
val type = spotifyLink.substringBeforeLast('/', "Error").substringAfterLast('/') val type = spotifyLink.substringBeforeLast('/', "Error").substringAfterLast('/')

View File

@ -41,25 +41,31 @@ class YoutubeProvider @Inject constructor(
* HI-RES Url: https://i.ytimg.com/vi/$searchId/maxresdefault.jpg" * HI-RES Url: https://i.ytimg.com/vi/$searchId/maxresdefault.jpg"
* Normal Url: https://i.ytimg.com/vi/$searchId/hqdefault.jpg" * Normal Url: https://i.ytimg.com/vi/$searchId/hqdefault.jpg"
* */ * */
private val sampleDomain2 = "youtu.be" private val sampleDomain1 = "music.youtube.com"
private val sampleDomain1 = "youtube.com" private val sampleDomain2 = "youtube.com"
private val sampleDomain3 = "youtu.be"
override suspend fun query(fullLink: String): PlatformQueryResult?{ override suspend fun query(fullLink: String): PlatformQueryResult?{
val link = fullLink.removePrefix("https://").removePrefix("http://") val link = fullLink.removePrefix("https://").removePrefix("http://")
if(link.contains("playlist",true) || link.contains("list",true)){ if(link.contains("playlist",true) || link.contains("list",true)){
// Given Link is of a Playlist // Given Link is of a Playlist
log("YT Play",link) log("YT Play",link)
val playlistId = link.substringAfter("?list=").substringAfter("&list=").substringBefore("&") val playlistId = link.substringAfter("?list=").substringAfter("&list=").substringBefore("&").substringBefore("?")
return getYTPlaylist( return getYTPlaylist(
playlistId playlistId
) )
}else{//Given Link is of a Video }else{//Given Link is of a Video
var searchId = "error" var searchId = "error"
if(link.contains(sampleDomain1,true) ){ when{
searchId = link.substringAfterLast("=","error") link.contains(sampleDomain1,true) -> {//Youtube Music
searchId = link.substringAfterLast("/","error").substringBefore("&").substringAfterLast("=")
}
link.contains(sampleDomain2,true) -> {//Standard Youtube Link
searchId = link.substringAfterLast("=","error").substringBefore("&")
}
link.contains(sampleDomain3,true) -> {//Shortened Youtube Link
searchId = link.substringAfterLast("/","error").substringBefore("&")
} }
if(link.contains(sampleDomain2,true) ){
searchId = link.substringAfterLast("/","error")
} }
return if(searchId != "error") { return if(searchId != "error") {
getYTTrack( getYTTrack(
@ -214,7 +220,7 @@ class YoutubeProvider @Inject constructor(
} }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
showDialog("An Error Occurred While Processing!") showDialog("An Error Occurred While Processing!,$searchId")
} }
} }
return if(result.title.isNotBlank()) result return if(result.title.isNotBlank()) result

View File

@ -124,16 +124,21 @@ fun AboutColumn(mainActivity: MainActivity,modifier: Modifier = Modifier) {
modifier = Modifier.clickable( modifier = Modifier.clickable(
onClick = { openPlatform("com.spotify.music","http://open.spotify.com",ctx) }) onClick = { openPlatform("com.spotify.music","http://open.spotify.com",ctx) })
) )
Spacer(modifier = modifier.padding(start = 24.dp)) Spacer(modifier = modifier.padding(start = 16.dp))
Icon(imageVector = vectorResource(id = R.drawable.ic_gaana ),tint = Color.Unspecified, Icon(imageVector = vectorResource(id = R.drawable.ic_gaana ),tint = Color.Unspecified,
modifier = Modifier.clickable( modifier = Modifier.clickable(
onClick = { openPlatform("com.gaana","http://gaana.com",ctx) }) onClick = { openPlatform("com.gaana","http://gaana.com",ctx) })
) )
Spacer(modifier = modifier.padding(start = 24.dp)) Spacer(modifier = modifier.padding(start = 16.dp))
Icon(imageVector = vectorResource(id = R.drawable.ic_youtube),tint = Color.Unspecified, Icon(imageVector = vectorResource(id = R.drawable.ic_youtube),tint = Color.Unspecified,
modifier = Modifier.clickable( modifier = Modifier.clickable(
onClick = { openPlatform("com.google.android.youtube","http://m.youtube.com",ctx) }) onClick = { openPlatform("com.google.android.youtube","http://m.youtube.com",ctx) })
) )
Spacer(modifier = modifier.padding(start = 12.dp))
Icon(imageVector = vectorResource(id = R.drawable.ic_youtube_music_logo),tint = Color.Unspecified,
modifier = Modifier.clickable(
onClick = { openPlatform("com.google.android.apps.youtube.music","https://music.youtube.com/",ctx) })
)
} }
} }
} }

View File

@ -0,0 +1,22 @@
<!--
~ Copyright (c) 2021 Shabinder Singh
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<vector android:height="44dp" android:viewportHeight="192"
android:viewportWidth="192" android:width="44dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF0000" android:pathData="M96,96m-88,0a88,88 0,1 1,176 0a88,88 0,1 1,-176 0"/>
<path android:fillColor="#FFFFFF" android:pathData="M96,54.04c23.14,0 41.96,18.82 41.96,41.96S119.14,137.96 96,137.96S54.04,119.14 54.04,96S72.86,54.04 96,54.04M96,50c-25.41,0 -46,20.59 -46,46s20.59,46 46,46s46,-20.59 46,-46S121.41,50 96,50L96,50z"/>
<path android:fillColor="#FFFFFF" android:pathData="M80,119l39,-24l-39,-22z"/>
</vector>

View File

@ -17,8 +17,8 @@
<AppUpdater> <AppUpdater>
<update> <update>
<latestVersion>2.0.1</latestVersion> <latestVersion>2.1</latestVersion>
<latestVersionCode>13</latestVersionCode> <latestVersionCode>14</latestVersionCode>
<url>https://github.com/Shabinder/SpotiFlyer/releases/</url> <url>https://github.com/Shabinder/SpotiFlyer/releases/</url>
</update> </update>
</AppUpdater> </AppUpdater>

View File

@ -18,12 +18,12 @@
buildscript { buildscript {
ext { ext {
compose_version = '1.0.0-alpha09' compose_version = '1.0.0-alpha09'
lifecycle_version = '2.3.0-rc01'
room_version = "2.2.6"
okhttp_version = "4.9.0"
coroutines_version = "1.4.2" coroutines_version = "1.4.2"
coil_version = "0.4.1" coil_version = "0.4.1"
kotlin_version = "1.4.21" kotlin_version = "1.4.21"
lifecycle_version = '2.3.0-rc01'
room_version = "2.2.6"
okhttp_version = "4.9.0"
hilt_version = '2.30.1-alpha' hilt_version = '2.30.1-alpha'
} }