mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Fixed minor bugs
This commit is contained in:
parent
fbdad7ee8d
commit
ca6196da54
@ -40,30 +40,35 @@ class Settings : PreferenceFragmentCompat() {
|
||||
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
getContent = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri ->
|
||||
getContent = registerForActivityResult(ActivityResultContracts.GetContent()) { uri: Uri? ->
|
||||
|
||||
var zipfile = ZipFile(UriUtils.uri2File(uri))
|
||||
if(uri != null){
|
||||
var zipfile = ZipFile(UriUtils.uri2File(uri))
|
||||
|
||||
var zipentry =
|
||||
zipfile.getEntry("Takeout/YouTube and YouTube Music/subscriptions/subscriptions.csv")
|
||||
var zipentry =
|
||||
zipfile.getEntry("Takeout/YouTube and YouTube Music/subscriptions/subscriptions.csv")
|
||||
|
||||
var inputStream = zipfile.getInputStream(zipentry)
|
||||
var inputStream = zipfile.getInputStream(zipentry)
|
||||
|
||||
val baos = ByteArrayOutputStream()
|
||||
val baos = ByteArrayOutputStream()
|
||||
|
||||
inputStream.use { it.copyTo(baos) }
|
||||
inputStream.use { it.copyTo(baos) }
|
||||
|
||||
var subscriptions = baos.toByteArray().decodeToString()
|
||||
var subscriptions = baos.toByteArray().decodeToString()
|
||||
|
||||
var subscribedCount = 0
|
||||
var subscribedCount = 0
|
||||
|
||||
for(text in subscriptions.lines()){
|
||||
if(text.take(24) != "Channel Id,Channel Url,C" && !text.take(24).isEmpty()){
|
||||
subscribe(text.take(24))
|
||||
subscribedCount++
|
||||
Log.d(TAG, "subscribed: " + text +" total: " + subscribedCount)
|
||||
for(text in subscriptions.lines()){
|
||||
if(text.take(24) != "Channel Id,Channel Url,C" && !text.take(24).isEmpty()){
|
||||
subscribe(text.take(24))
|
||||
subscribedCount++
|
||||
Log.d(TAG, "subscribed: " + text +" total: " + subscribedCount)
|
||||
}
|
||||
}
|
||||
|
||||
Toast.makeText(context, "Subscribed to " + subscribedCount + " channels.", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
}
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
@ -29,6 +29,6 @@
|
||||
<string name="downloadfailed">Download Failed!</string>
|
||||
<string name="vlc">Open in VLC</string>
|
||||
<string name="vlcerror">Can\'t open in VLC. Maybe it\'s not installed yet?</string>
|
||||
<string name="import_from_yt">Import subscriptions data from youtube</string>
|
||||
<string name="import_from_yt">Import subscriptions from youtube</string>
|
||||
|
||||
</resources>
|
@ -33,6 +33,7 @@
|
||||
<androidx.preference.Preference
|
||||
app:key="import_from_yt"
|
||||
app:title="@string/import_from_yt"
|
||||
android:hint="This is my hint"
|
||||
/>
|
||||
|
||||
</androidx.preference.PreferenceScreen>
|
Loading…
x
Reference in New Issue
Block a user