added invidious formats and unified download card for a single item

pull/44/head
Denis Çerri 4 years ago
parent c4c4e7eab1
commit d124b8fb5f
No known key found for this signature in database
GPG Key ID: 96B3554AF5B193EE

@ -320,7 +320,7 @@
<PersistentState>
<option name="values">
<map>
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/download/baseline_download_24.xml" />
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/schedule/baseline_schedule_24.xml" />
</map>
</option>
</PersistentState>
@ -331,7 +331,7 @@
<option name="values">
<map>
<entry key="color" value="00a6ff" />
<entry key="outputName" value="ic_downloads" />
<entry key="outputName" value="ic_clock" />
<entry key="sourceFile" value="C:\Users\denis\Desktop\adaptiveproduct_youtube_foreground_color_108 (1).svg" />
</map>
</option>

@ -24,6 +24,9 @@ data class DownloadItem(
val website: String,
val downloadSize: String,
val playlistTitle: String,
val embedSubs: Boolean,
val addChapters: Boolean,
val SaveThumb: Boolean,
@ColumnInfo(defaultValue = "Queued")
val status: String,
val workID: Int

@ -2,14 +2,20 @@ package com.deniscerri.ytdlnis.database.models
import androidx.room.Entity
import androidx.room.PrimaryKey
import com.google.gson.annotations.SerializedName
@Entity(tableName = "formats")
data class Format(
var itemId: Int,
@SerializedName(value = "format", alternate = ["type"])
val format: String,
@SerializedName(value = "format_id", alternate = ["itag"])
val format_id: String,
@SerializedName(value = "ext", alternate = ["container", ""])
val ext: String,
@SerializedName(value = "filesize", alternate = ["clen"])
val filesize: Long,
@SerializedName(value = "format_note", alternate = ["resolution", "audioQuality"])
val format_note: String
){
@PrimaryKey(autoGenerate = true)

@ -79,7 +79,7 @@ class ResultRepository(private val resultDao: ResultDao, private val formatDao:
val tmpVids = tmp.videos
val tmpToken = tmp.nextPageToken
tmpVids.forEach {
val id = resultDao.insert(it!!.resultItem);
val id = resultDao.insert(it!!.resultItem)
addFormats(it.formats,id)
}
if (tmpToken.isEmpty()) break
@ -94,7 +94,7 @@ class ResultRepository(private val resultDao: ResultDao, private val formatDao:
if (resetResults) deleteAll()
val items = infoUtil.getFromYTDL(inputQuery)
items.forEach {
val id = resultDao.insert(it!!.resultItem);
val id = resultDao.insert(it!!.resultItem)
addFormats(it.formats,id)
}
} catch (e: Exception) {
@ -104,7 +104,7 @@ class ResultRepository(private val resultDao: ResultDao, private val formatDao:
private suspend fun addFormats(formats : ArrayList<Format>, id: Long){
formats.forEach { f ->
if (f.filesize == 0.toLong()) return@forEach
if (f.filesize == 0L) return@forEach
f.itemId = id.toInt()
formatDao.insert(f)
}

@ -1,4 +1,4 @@
package com.deniscerri.ytdlnis.service
package com.deniscerri.ytdlnis.service.api
import com.deniscerri.ytdlnis.database.models.ResultItem
import com.google.gson.JsonArray

@ -1,4 +1,4 @@
package com.deniscerri.ytdlnis.service
package com.deniscerri.ytdlnis.service.api
import com.google.gson.JsonArray
import com.google.gson.JsonObject

@ -288,6 +288,16 @@ class InfoUtil(context: Context) {
val duration = formatIntegerDuration(obj.getInt("lengthSeconds"))
val thumb = "https://i.ytimg.com/vi/$id/hqdefault.jpg"
val url = "https://www.youtube.com/watch?v=$id"
val formats : ArrayList<Format> = ArrayList()
if (obj.has("adaptiveFormats")){
val formatsInJSON = obj.getJSONArray("adaptiveFormats");
for (f in 0 until formatsInJSON.length()){
val format = formatsInJSON.getJSONObject(f)
if(!format.has("container")) continue
formats.add(Gson().fromJson(format.toString(), Format::class.java))
}
}
video = ResultItemWithFormats(
ResultItem(
url,
@ -298,7 +308,7 @@ class InfoUtil(context: Context) {
"youtube",
"",
),
ArrayList()
formats
)
} catch (e: Exception) {
Log.e(TAG, e.toString())
@ -606,7 +616,7 @@ class InfoUtil(context: Context) {
companion object {
private const val TAG = "API MANAGER"
private const val invidousURL = "https://invidious.baczek.me/api/vvvvvv/"
private const val invidousURL = "https://invidious.nerdvpn.de/api/v1/"
private var countryCODE: String? = null
}
}

@ -0,0 +1,5 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="?android:colorAccent" android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
</vector>

@ -0,0 +1,6 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="?android:colorAccent" android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/>
<path android:fillColor="?android:colorAccent" android:pathData="M12.5,7H11v6l5.25,3.15 0.75,-1.23 -4.5,-2.67z"/>
</vector>

@ -0,0 +1,5 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="?android:colorAccent" android:pathData="M3,10h11v2H3V10zM3,8h11V6H3V8zM3,16h7v-2H3V16zM18.01,12.87l0.71,-0.71c0.39,-0.39 1.02,-0.39 1.41,0l0.71,0.71c0.39,0.39 0.39,1.02 0,1.41l-0.71,0.71L18.01,12.87zM17.3,13.58l-5.3,5.3V21h2.12l5.3,-5.3L17.3,13.58z"/>
</vector>

@ -0,0 +1,5 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="?android:colorAccent" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>

@ -14,30 +14,6 @@
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/bottom_sheet_title"
android:layout_width="wrap_content"
android:textSize="25sp"
android:textColor="?attr/colorOnSurface"
android:layout_height="wrap_content"
android:text="@string/download_audio" />
<TextView
android:id="@+id/bottom_sheet_author"
android:layout_width="wrap_content"
android:paddingTop="5dp"
android:textSize="15sp"
android:layout_height="wrap_content"
android:text="@string/configure_download" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -108,34 +84,6 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="end"
android:layout_margin="20dp"
android:orientation="horizontal">
<Button
style="@style/Widget.Material3.Button.OutlinedButton.Icon"
android:id="@+id/bottomsheet_cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
app:icon="@drawable/ic_cancel"
android:text="@string/cancel" />
<Button
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
android:id="@+id/bottomsheet_download_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/download"
app:icon="@drawable/ic_down"
android:autoLink="all"/>
</LinearLayout>
</LinearLayout>

@ -11,134 +11,291 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_margin="20dp"
android:orientation="vertical"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/result_card_constraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/bottom_sheet_title"
android:layout_width="wrap_content"
android:textSize="25sp"
android:textColor="?attr/colorOnSurface"
android:layout_height="wrap_content"
android:text="@string/download" />
<TextView
android:id="@+id/bottom_sheet_author"
android:layout_width="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:textSize="15sp"
android:layout_height="wrap_content"
android:text="@string/configure_download" />
<RelativeLayout
android:id="@+id/result_relative_layout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="H,16:9"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:paddingBottom="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<com.google.android.material.card.MaterialCardView
android:id="@+id/result_card_view"
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/title_textinput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
app:errorEnabled="true"
android:hint="@string/title"
style="@style/Widget.Material3.TextInputLayout.FilledBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardCornerRadius="10dp"
app:cardElevation="10dp"
app:cardMaxElevation="12dp"
app:cardBackgroundColor="@color/black"
app:cardPreventCornerOverlap="true"
android:checkable="true"
app:strokeWidth="0dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/result_image_view"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:inputType="text"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/author_textinput"
android:layout_width="0dp"
android:layout_weight="45"
android:layout_height="wrap_content"
app:errorEnabled="true"
android:hint="@string/author"
style="@style/Widget.Material3.TextInputLayout.FilledBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="100dp"
android:dividerPadding="5dp"
android:orientation="vertical">
<TextView
android:id="@+id/result_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingEnd="10dp"
android:paddingStart="10dp"
android:textSize="17sp"
android:textColor="@color/white"
android:textStyle="bold"
android:shadowRadius="2"
android:shadowDx="4"
android:shadowDy="4"
android:shadowColor="@color/black" />
<TextView
android:id="@+id/author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:paddingEnd="10dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:textSize="12sp"
android:textColor="@color/white"
android:textStyle="bold"
android:shadowRadius="1.5"
android:shadowDx="4"
android:shadowDy="4"
android:shadowColor="@color/black" />
</LinearLayout>
<TextView
android:id="@+id/duration"
android:inputType="text"
android:layout_height="wrap_content"
/>
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/audio_format"
style="@style/Widget.Material3.TextInputLayout.FilledBox.ExposedDropdownMenu"
android:layout_width="0dp"
android:paddingStart="10dp"
android:layout_weight="45"
android:layout_height="wrap_content"
android:hint="@string/audio_format">
<AutoCompleteTextView
android:id="@+id/audio_format_textview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:paddingEnd="10dp"
android:paddingBottom="20dp"
android:paddingStart="10dp"
android:textSize="12sp"
android:textColor="@color/white"
android:textStyle="bold"
android:shadowRadius="1.5"
android:shadowDx="4"
android:shadowDy="4"
android:shadowColor="@color/black" />
</com.google.android.material.card.MaterialCardView>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.tabs.TabLayout
android:layout_height="wrap_content"
android:inputType="none"
app:simpleItems="@array/music_formats"
/>
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
</LinearLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/outputPath_textinput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="match_parent">
app:errorEnabled="true"
android:hint="@string/save_dir"
style="@style/Widget.Material3.TextInputLayout.FilledBox">
<com.google.android.material.tabs.TabItem
android:icon="@drawable/ic_music"
android:text="@string/audio"
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:inputType="text"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
/>
<com.google.android.material.tabs.TabItem
android:icon="@drawable/ic_video"
android:text="@string/video"
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.chip.ChipGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:selectionRequired="true"
app:singleLine="true"
app:singleSelection="true">
<com.google.android.material.chip.Chip
android:id="@+id/audioChip"
style="@style/Widget.Material3.Chip.Assist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checkable="true"
app:checkedIcon="@drawable/ic_check"
android:text="@string/audio"
app:chipIcon="@drawable/ic_music" />
<com.google.android.material.chip.Chip
android:id="@+id/videoChip"
style="@style/Widget.Material3.Chip.Assist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
android:text="@string/video"
android:checkable="true"
app:checkedIcon="@drawable/ic_check"
app:chipIcon="@drawable/ic_video" />
<com.google.android.material.tabs.TabItem
android:icon="@drawable/ic_baseline_keyboard_arrow_right_24"
<com.google.android.material.chip.Chip
android:id="@+id/commandChip"
style="@style/Widget.Material3.Chip.Assist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/run_command"
android:checkable="true"
app:checkedIcon="@drawable/ic_check"
app:chipIcon="@drawable/ic_baseline_keyboard_arrow_right_24" />
</com.google.android.material.chip.ChipGroup>
<LinearLayout
android:id="@+id/adjust_commands"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:textSize="15sp"
android:layout_height="wrap_content"
android:text="@string/adjust_templates" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/commands_chip_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:selectionRequired="false"
app:singleLine="true"
app:singleSelection="false">
<com.google.android.material.chip.Chip
android:id="@+id/newTemplate"
style="@style/Widget.Material3.Chip.Assist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/new_template"
app:chipIcon="@drawable/ic_plus" />
<com.google.android.material.chip.Chip
android:id="@+id/editSelected"
style="@style/Widget.Material3.Chip.Assist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/edit_selected"
app:chipIcon="@drawable/ic_edit" />
</com.google.android.material.chip.ChipGroup>
</LinearLayout>
<LinearLayout
android:id="@+id/adjust_video"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:paddingTop="5dp"
android:paddingBottom="10dp"
android:textSize="15sp"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
android:text="@string/adjust_video" />
<com.google.android.material.chip.ChipGroup
android:id="@+id/chipGroup"
android:layout_width="wrap_content"
app:singleLine="true"
android:layout_height="wrap_content">
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
<com.google.android.material.chip.Chip
android:id="@+id/embed_subtitles"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/embed_subtitles"/>
<com.google.android.material.chip.Chip
android:id="@+id/add_chapters"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/add_chapter"/>
<com.google.android.material.chip.Chip
android:id="@+id/save_thumbnail"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/save_thumb"/>
<com.google.android.material.chip.Chip
android:id="@+id/remove_audio"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/remove_audio"/>
</com.google.android.material.chip.ChipGroup>
</LinearLayout>
<View style="@style/Divider.Horizontal"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
</androidx.viewpager.widget.ViewPager>
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="end"
android:orientation="horizontal">
<Button
style="?attr/materialIconButtonOutlinedStyle"
android:id="@+id/bottomsheet_cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
app:icon="@drawable/ic_cancel" />
<Button
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
android:id="@+id/bottomsheet_schedule_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
app:icon="@drawable/ic_clock"
android:text="@string/schedule" />
<Button
style="@style/Widget.Material3.Button.ElevatedButton.Icon"
android:id="@+id/bottomsheet_download_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/download"
app:icon="@drawable/ic_down"
android:autoLink="all"/>
</LinearLayout>
</LinearLayout>

@ -30,8 +30,8 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.google.android.material.button.MaterialButton
style="@style/Widget.Material3.Button.IconButton"
<Button
style="?attr/materialIconButtonStyle"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_weight="0.01"
@ -50,8 +50,8 @@
android:textSize="16sp"
android:textStyle="bold" />
<com.google.android.material.button.MaterialButton
style="@style/Widget.Material3.Button.IconButton"
<Button
style="?attr/materialIconButtonStyle"
android:id="@+id/set_search_query_button"
android:layout_width="40dp"
android:layout_height="match_parent"

@ -151,4 +151,11 @@
<string name="unfound_file" translatable="false">/404.404</string>
<string name="file_transfer_notification_channel_name">File Transfers</string>
<string name="file_transfer_notification_channel_description">Notification showing the progress of moving files from the temporary folder to set destination</string>
<string name="save_dir">Save dir</string>
<string name="new_template">New template</string>
<string name="adjust_templates">Adjust templates</string>
<string name="edit_selected">Edit selected</string>
<string name="adjust_video">Adjust video</string>
<string name="remove_audio">Remove Audio</string>
<string name="schedule">Schedule</string>
</resources>

@ -25,7 +25,7 @@
<style name="Divider.Horizontal" parent="Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item> // You can change thickness here.
<item name="android:layout_marginBottom">20dp</item>
<item name="android:layout_marginBottom">10dp</item>
</style>
<style name="Divider.Vertical" parent="Divider">

Loading…
Cancel
Save