new small features
made progress bar as thick as the card and somewhat transparent, looks nicer made the download progress not cut off and be seamless when transitioning from intermediate to solid colors renamed history tab to downloads added videopath to downloaded items and if they are not in the filesystem, they are greyed out made updating app as a toggle in the main settings page. moved update ytdl there aswell fixed not getting all playlist items from generic ytdl request brought back the default api key. If the key is throttled, it will try to use the user's custom youtube api key. If that key is throttled too, it will use the generic request as a last resort
This commit is contained in:
parent
5bd20ad5fd
commit
3936e83578
22 changed files with 294 additions and 185 deletions
|
|
@ -320,7 +320,7 @@
|
|||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/vpn_key/baseline_vpn_key_24.xml" />
|
||||
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialiconsoutlined/cloud_download/outline_cloud_download_24.xml" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
|
|
@ -331,7 +331,7 @@
|
|||
<option name="values">
|
||||
<map>
|
||||
<entry key="color" value="00a6ff" />
|
||||
<entry key="outputName" value="ic_key" />
|
||||
<entry key="outputName" value="ic_outline_cloud_download_24" />
|
||||
<entry key="sourceFile" value="C:\Users\denis\Desktop\adaptiveproduct_youtube_foreground_color_108 (1).svg" />
|
||||
</map>
|
||||
</option>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
<entry key="..\:/Users/denis/Desktop/ytdlnis/ytdlnis/app/src/main/res/xml/shortcuts.xml" value="0.13852073535699017" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.22" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_announcement.xml" value="0.1275" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_app_icon.xml" value="0.1965" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_back.xml" value="0.109" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_baseline_keyboard_arrow_right_24.xml" value="0.109" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_chapters.xml" value="0.109" />
|
||||
|
|
@ -45,6 +46,7 @@
|
|||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_delete_all.xml" value="0.109" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_down.xml" value="0.109" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_download.xml" value="0.1275" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_downloads.xml" value="0.2395" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_go_up.xml" value="0.1275" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_home.xml" value="0.1275" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_image.xml" value="0.109" />
|
||||
|
|
@ -70,6 +72,7 @@
|
|||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/ic_video_stopped.xml" value="0.14" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/drawable/transparent_background.xml" value="0.1965" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/layout/activity_custom_command.xml" value="0.15940685820203893" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/layout/activity_download_queue.xml" value="0.36666666666666664" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/layout/activity_main.xml" value="0.18" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/layout/activity_settings.xml" value="0.16875" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/layout/download_all_card.xml" value="0.25" />
|
||||
|
|
@ -96,7 +99,7 @@
|
|||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/xml/about_preferences.xml" value="0.16875" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/xml/display_preferences.xml" value="0.16875" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/xml/download_preferences.xml" value="0.16875" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/xml/more_preferences.xml" value="0.20555555555555555" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/xml/more_preferences.xml" value="0.22" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/xml/notification_preferences.xml" value="0.16875" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/xml/root_preferences.xml" value="0.25" />
|
||||
<entry key="..\:/Users/denis/Documents/GitHub/ytdlnis/app/src/main/res/xml/update_preferences.xml" value="0.16875" />
|
||||
|
|
|
|||
61
.idea/navEditor.xml
Normal file
61
.idea/navEditor.xml
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="navEditor-manualLayoutAlgorithm2">
|
||||
<option name="myPositions">
|
||||
<map>
|
||||
<entry key="my_nav.xml">
|
||||
<value>
|
||||
<LayoutPositions>
|
||||
<option name="myPositions">
|
||||
<map>
|
||||
<entry key="moreFragment">
|
||||
<value>
|
||||
<LayoutPositions>
|
||||
<option name="myPosition">
|
||||
<Point>
|
||||
<option name="x" value="-9" />
|
||||
<option name="y" value="28" />
|
||||
</Point>
|
||||
</option>
|
||||
<option name="myPositions">
|
||||
<map>
|
||||
<entry key="action_moreFragment_to_settingsFragment">
|
||||
<value>
|
||||
<LayoutPositions />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</LayoutPositions>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="settingsFragment">
|
||||
<value>
|
||||
<LayoutPositions>
|
||||
<option name="myPosition">
|
||||
<Point>
|
||||
<option name="x" value="260" />
|
||||
<option name="y" value="157" />
|
||||
</Point>
|
||||
</option>
|
||||
<option name="myPositions">
|
||||
<map>
|
||||
<entry key="action_settingsFragment_to_moreFragment">
|
||||
<value>
|
||||
<LayoutPositions />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</LayoutPositions>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</LayoutPositions>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
|
|
@ -68,6 +68,8 @@ dependencies {
|
|||
implementation 'androidx.core:core:1.8.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
||||
implementation 'androidx.preference:preference:1.2.0'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.5.2'
|
||||
implementation 'androidx.navigation:navigation-ui:2.5.2'
|
||||
testImplementation "junit:junit:$junitVer"
|
||||
androidTestImplementation "androidx.test.ext:junit:$androidJunitVer"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVer"
|
||||
|
|
|
|||
|
|
@ -49,6 +49,10 @@
|
|||
android:name=".DownloaderService"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
<meta-data
|
||||
android:name = "ytAPIkey"
|
||||
android:value = "${ytAPI}"
|
||||
/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
package com.deniscerri.ytdlnis;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
|
@ -13,7 +15,6 @@ import android.widget.Toast;
|
|||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.deniscerri.ytdlnis.database.Video;
|
||||
import com.deniscerri.ytdlnis.databinding.ActivityMainBinding;
|
||||
import com.deniscerri.ytdlnis.page.HistoryFragment;
|
||||
|
|
@ -99,11 +100,11 @@ public class MainActivity extends AppCompatActivity{
|
|||
this.setTitle(R.string.app_name);;
|
||||
}
|
||||
replaceFragment(homeFragment);
|
||||
}else if(id == R.id.history){
|
||||
}else if(id == R.id.downloads){
|
||||
if(lastFragment == historyFragment){
|
||||
historyFragment.scrollToTop();
|
||||
}else {
|
||||
this.setTitle(getString(R.string.history));
|
||||
this.setTitle(getString(R.string.downloads));
|
||||
}
|
||||
replaceFragment(historyFragment);
|
||||
}else if(id == R.id.more){
|
||||
|
|
@ -215,8 +216,11 @@ public class MainActivity extends AppCompatActivity{
|
|||
}
|
||||
|
||||
private void checkUpdate(){
|
||||
UpdateUtil updateUtil = new UpdateUtil(this);
|
||||
updateUtil.updateApp();
|
||||
SharedPreferences preferences = context.getSharedPreferences("root_preferences", Activity.MODE_PRIVATE);
|
||||
if(preferences.getBoolean("update_app", false)){
|
||||
UpdateUtil updateUtil = new UpdateUtil(this);
|
||||
updateUtil.updateApp();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateHistoryFragment(){
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.deniscerri.ytdlnis.adapter;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
|
|
@ -21,6 +23,7 @@ import com.deniscerri.ytdlnis.R;
|
|||
import com.deniscerri.ytdlnis.database.Video;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class HistoryRecyclerViewAdapter extends RecyclerView.Adapter<HistoryRecyclerViewAdapter.ViewHolder> {
|
||||
|
|
@ -97,6 +100,12 @@ public class HistoryRecyclerViewAdapter extends RecyclerView.Adapter<HistoryRecy
|
|||
btn.setBackground(ContextCompat.getDrawable(context, R.drawable.ic_video));
|
||||
}
|
||||
|
||||
File file = new File(video.getDownloadPath());
|
||||
if(!file.exists()){
|
||||
thumbnail.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix(){{setSaturation(0f);}}));
|
||||
thumbnail.setAlpha(0.7f);
|
||||
}
|
||||
|
||||
card.setOnClickListener(view -> onItemClickListener.onCardClick(position));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,10 +110,13 @@ public class HomeFragment extends Fragment implements HomeRecyclerViewAdapter.On
|
|||
public void onDownloadProgress(DownloadInfo info) {
|
||||
activity.runOnUiThread(() -> {
|
||||
try{
|
||||
int progress = info.getProgress();
|
||||
progressBar = fragmentView.findViewWithTag(info.getVideo().getVideoId()+"##progress");
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setIndeterminate(false);
|
||||
progressBar.setProgress(info.getProgress());
|
||||
if (progress > 1){
|
||||
progressBar.setIndeterminate(false);
|
||||
progressBar.setProgress(info.getProgress());
|
||||
}
|
||||
}catch(Exception ignored){}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,13 @@
|
|||
package com.deniscerri.ytdlnis.page;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
|
||||
import com.deniscerri.ytdlnis.R;
|
||||
import com.deniscerri.ytdlnis.util.UpdateUtil;
|
||||
|
||||
public class MoreFragment extends PreferenceFragmentCompat {
|
||||
Preference updateYTDL;
|
||||
Preference updateApp;
|
||||
public static final String TAG = "MoreFragment";
|
||||
private UpdateUtil updateUtil;
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||
setPreferencesFromResource(R.xml.more_preferences, rootKey);
|
||||
|
||||
updateYTDL = findPreference("update_ytdl");
|
||||
updateApp = findPreference("update_app");
|
||||
|
||||
updateUtil = new UpdateUtil(getContext());
|
||||
|
||||
updateYTDL.setOnPreferenceClickListener(preference -> {
|
||||
updateUtil.updateYoutubeDL();
|
||||
return true;
|
||||
});
|
||||
|
||||
updateApp.setOnPreferenceClickListener(preference -> {
|
||||
if(!updateUtil.updateApp()){
|
||||
Toast.makeText(getContext(), R.string.you_are_in_latest_version, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
ListPreference videoFormat;
|
||||
SeekBarPreference audioQuality;
|
||||
|
||||
Preference updateYTDL;
|
||||
SwitchPreferenceCompat updateApp;
|
||||
Preference version;
|
||||
|
||||
private UpdateUtil updateUtil;
|
||||
|
|
@ -58,7 +60,6 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
setPreferencesFromResource(R.xml.root_preferences, rootKey);
|
||||
|
||||
updateUtil = new UpdateUtil(requireContext());
|
||||
|
||||
initPreferences();
|
||||
initListeners();
|
||||
}
|
||||
|
|
@ -85,6 +86,8 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
videoFormat = findPreference("video_format");
|
||||
audioQuality = findPreference("audio_quality");
|
||||
|
||||
updateYTDL = findPreference("update_ytdl");
|
||||
updateApp = findPreference("update_app");
|
||||
version = findPreference("version");
|
||||
version.setSummary(BuildConfig.VERSION_NAME);
|
||||
|
||||
|
|
@ -110,6 +113,7 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
editor.putString("audio_format", audioFormat.getValue());
|
||||
editor.putString("video_format", videoFormat.getValue());
|
||||
editor.putInt("audio_quality", audioQuality.getValue());
|
||||
editor.putBoolean("update_app", updateApp.isChecked());
|
||||
|
||||
editor.apply();
|
||||
}
|
||||
|
|
@ -222,6 +226,18 @@ public class SettingsFragment extends PreferenceFragmentCompat {
|
|||
return true;
|
||||
});
|
||||
|
||||
updateYTDL.setOnPreferenceClickListener(preference -> {
|
||||
updateUtil.updateYoutubeDL();
|
||||
return true;
|
||||
});
|
||||
|
||||
updateApp.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
boolean enable = (Boolean) newValue;
|
||||
editor.putBoolean("update_app", enable);
|
||||
editor.apply();
|
||||
return true;
|
||||
});
|
||||
|
||||
version.setOnPreferenceClickListener(preference -> {
|
||||
if(!updateUtil.updateApp()){
|
||||
Toast.makeText(getContext(), R.string.you_are_in_latest_version, Toast.LENGTH_SHORT).show();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.text.Html;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
|
@ -35,6 +36,9 @@ public class InfoUtil {
|
|||
try{
|
||||
SharedPreferences sharedPreferences = context.getSharedPreferences("root_preferences", Activity.MODE_PRIVATE);
|
||||
key = sharedPreferences.getString("api_key", "");
|
||||
applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
|
||||
if (key.isEmpty()) key = applicationInfo.metaData.getString("ytAPIkey");
|
||||
Log.e(TAG, key);
|
||||
dbManager = new DBManager(context);
|
||||
|
||||
Thread thread = new Thread(() -> {
|
||||
|
|
@ -60,6 +64,7 @@ public class InfoUtil {
|
|||
videos = new ArrayList<>();
|
||||
//short data
|
||||
JSONObject res = genericRequest("https://youtube.googleapis.com/youtube/v3/search?part=snippet&q="+query+"&maxResults=25®ionCode="+countryCODE+"&key="+key);
|
||||
if (!res.has("items")) return getFromYTDL(query);
|
||||
JSONArray dataArray = res.getJSONArray("items");
|
||||
|
||||
//extra data
|
||||
|
|
@ -110,6 +115,7 @@ public class InfoUtil {
|
|||
String url = "https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet&pageToken="+nextPageToken+"&maxResults=50®ionCode="+countryCODE+"&playlistId="+id+"&key="+key;
|
||||
//short data
|
||||
JSONObject res = genericRequest(url);
|
||||
if (!res.has("items")) return new PlaylistTuple("", getFromYTDL("https://www.youtube.com/playlist?list="+id));
|
||||
JSONArray dataArray = res.getJSONArray("items");
|
||||
|
||||
//extra data
|
||||
|
|
@ -155,6 +161,7 @@ public class InfoUtil {
|
|||
|
||||
//short data
|
||||
JSONObject res = genericRequest("https://youtube.googleapis.com/youtube/v3/videos?part=snippet,contentDetails&id="+id+"&key="+key);
|
||||
if (!res.has("items")) return getFromYTDL("https://www.youtube.com/watch?v="+id).get(0);
|
||||
String duration = res.getJSONArray("items").getJSONObject(0).getJSONObject("contentDetails").getString("duration");
|
||||
duration = formatDuration(duration);
|
||||
|
||||
|
|
@ -264,59 +271,57 @@ public class InfoUtil {
|
|||
try {
|
||||
YoutubeDLRequest request = new YoutubeDLRequest(query);
|
||||
request.addOption("--flat-playlist");
|
||||
request.addOption("-J");
|
||||
request.addOption("-j");
|
||||
request.addOption("--skip-download");
|
||||
request.addOption("-R", "1");
|
||||
request.addOption("--socket-timeout", "5");
|
||||
if (!query.contains("http")) request.addOption("--default-search", "ytsearch25");
|
||||
|
||||
YoutubeDLResponse youtubeDLResponse = YoutubeDL.getInstance().execute(request);
|
||||
JSONObject jsonObject = new JSONObject(youtubeDLResponse.getOut());
|
||||
String[] results;
|
||||
try {
|
||||
results = youtubeDLResponse.getOut().split(System.getProperty("line.separator"));
|
||||
}catch(Exception e){
|
||||
results = new String[]{youtubeDLResponse.getOut()};
|
||||
}
|
||||
|
||||
int isPlaylist = 0;
|
||||
JSONObject pl = new JSONObject(results[0]);
|
||||
if (pl.has("playlist")){
|
||||
if (! pl.getString("playlist").equals(query)) isPlaylist = 1;
|
||||
}
|
||||
|
||||
for (String result : results) {
|
||||
JSONObject jsonObject = new JSONObject(result);
|
||||
if (jsonObject.getString("title").equals("[Private video]")) continue;
|
||||
|
||||
if(!jsonObject.has("entries")){
|
||||
String url = jsonObject.getString("webpage_url");
|
||||
String thumb = "";
|
||||
if (jsonObject.has("thumbnail")){
|
||||
thumb = jsonObject.getString("thumbnail");
|
||||
}else {
|
||||
JSONArray thumbs = jsonObject.getJSONArray("thumbnails");
|
||||
thumb = thumbs.getJSONObject(thumbs.length()-1).getString("url");
|
||||
}
|
||||
|
||||
String website = "";
|
||||
if (jsonObject.has("ie_key")) website = jsonObject.getString("ie_key");
|
||||
else website = jsonObject.getString("extractor");
|
||||
|
||||
|
||||
videos.add(new Video(
|
||||
jsonObject.getString("id"),
|
||||
url,
|
||||
jsonObject.getString("title"),
|
||||
jsonObject.getString("uploader"),
|
||||
formatIntegerDuration(jsonObject.getInt("duration")),
|
||||
jsonObject.getString("thumbnail"),
|
||||
thumb,
|
||||
dbManager.checkDownloaded(url, "audio"),
|
||||
dbManager.checkDownloaded(url, "video"),
|
||||
0,
|
||||
jsonObject.getString("extractor"))
|
||||
isPlaylist,
|
||||
website)
|
||||
);
|
||||
}else{
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("entries");
|
||||
|
||||
for (int i = 0; i < jsonArray.length(); i++){
|
||||
jsonObject = jsonArray.getJSONObject(i);
|
||||
String url = jsonObject.getString("url");
|
||||
String thumb = "";
|
||||
if (jsonObject.has("thumbnail")){
|
||||
thumb = jsonObject.getString("thumbnail");
|
||||
}else {
|
||||
JSONArray thumbs = jsonObject.getJSONArray("thumbnails");
|
||||
thumb = thumbs.getJSONObject(thumbs.length()-1).getString("url");
|
||||
}
|
||||
String website = "";
|
||||
if (jsonObject.has("ie_key")) website = jsonObject.getString("ie_key");
|
||||
else website = jsonObject.getString("extractor");
|
||||
|
||||
videos.add(new Video(
|
||||
jsonObject.getString("id"),
|
||||
url,
|
||||
jsonObject.getString("title"),
|
||||
jsonObject.getString("uploader"),
|
||||
formatIntegerDuration(jsonObject.getInt("duration")),
|
||||
thumb,
|
||||
dbManager.checkDownloaded(url, "audio"),
|
||||
dbManager.checkDownloaded(url, "video"),
|
||||
0,
|
||||
website)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -335,6 +340,8 @@ public class InfoUtil {
|
|||
//extra data from the same videos
|
||||
JSONObject contentDetails = genericRequest("https://www.googleapis.com/youtube/v3/videos?part=contentDetails&chart=mostPopular&videoCategoryId=10®ionCode="+countryCODE+"&maxResults=25&key="+key);
|
||||
|
||||
if(!contentDetails.has("items")) return new ArrayList<>();
|
||||
|
||||
JSONArray dataArray = res.getJSONArray("items");
|
||||
JSONArray extraDataArray = contentDetails.getJSONArray("items");
|
||||
for(int i = 0; i < dataArray.length(); i++){
|
||||
|
|
@ -358,55 +365,30 @@ public class InfoUtil {
|
|||
}
|
||||
|
||||
public String formatDuration(String dur){
|
||||
|
||||
if(dur.equals("P0D")){
|
||||
return "LIVE";
|
||||
}
|
||||
|
||||
boolean hours = false;
|
||||
String duration = "";
|
||||
String tmp = "";
|
||||
String hours = "";
|
||||
String minutes = "";
|
||||
String seconds = "";
|
||||
//removing P
|
||||
dur = dur.substring(1);
|
||||
for(int i = 0; i < dur.length(); i++){
|
||||
char c = dur.charAt(i);
|
||||
if(!Character.isDigit(c)){
|
||||
int nr = Character.getNumericValue(c);
|
||||
if(nr < 10){
|
||||
tmp = "0" + tmp;
|
||||
}
|
||||
if (c == 'D'){
|
||||
hours = String.valueOf(Integer.parseInt(tmp) * 24);
|
||||
}else if(c == 'T'){
|
||||
continue;
|
||||
}else if(c == 'H'){
|
||||
hours = tmp;
|
||||
}else if(c == 'M'){
|
||||
minutes = tmp;
|
||||
}else if(c == 'S'){
|
||||
seconds = tmp;
|
||||
}
|
||||
tmp = "";
|
||||
continue;
|
||||
}
|
||||
tmp = tmp + c;
|
||||
dur = dur.substring(2);
|
||||
if (dur.contains("H")) {
|
||||
hours = true;
|
||||
duration += String.format(Locale.getDefault(), "%02d", Integer.parseInt(dur.substring(0, dur.indexOf("H")))) + ":";
|
||||
dur = dur.substring(dur.indexOf("H")+1);
|
||||
}
|
||||
if (dur.contains("M")) {
|
||||
duration += String.format(Locale.getDefault(), "%02d", Integer.parseInt(dur.substring(0, dur.indexOf("M")))) + ":";
|
||||
dur = dur.substring(dur.indexOf("M")+1);
|
||||
}else if(hours) duration += "00:";
|
||||
if (dur.contains("S")){
|
||||
if(duration.isEmpty()) duration = "00:";
|
||||
duration += String.format(Locale.getDefault(), "%02d", Integer.parseInt(dur.substring(0, dur.indexOf("S"))));
|
||||
}else{
|
||||
duration += "00";
|
||||
}
|
||||
|
||||
if(seconds.isEmpty()) seconds = "00";
|
||||
else if(Integer.parseInt(seconds) < 10) seconds = "0" + seconds;
|
||||
if(minutes.isEmpty()){
|
||||
minutes = "0";
|
||||
}
|
||||
duration = minutes + ":" + seconds;
|
||||
|
||||
if(!hours.isEmpty()){
|
||||
if(Integer.parseInt(minutes) < 10) minutes = "0" + minutes;
|
||||
duration = hours + ":" + minutes + ":" + seconds;
|
||||
}
|
||||
|
||||
if(duration.equals("0:00:00")){
|
||||
if(duration.equals("00:00")){
|
||||
duration = "";
|
||||
}
|
||||
|
||||
|
|
|
|||
15
app/src/main/res/drawable/ic_app_icon.xml
Normal file
15
app/src/main/res/drawable/ic_app_icon.xml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:name="vector"
|
||||
android:width="200dp"
|
||||
android:gravity="fill_horizontal|fill_vertical"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:name="path"
|
||||
android:pathData="M 73.977 46.512 C 75.734 48.222 76.781 50.662 76.872 53.315 C 76.945 55.412 77 57.629 77 59.482 C 77 61.335 76.945 63.552 76.872 65.649 C 76.718 70.133 73.835 74.006 69.404 74.78 C 65.706 75.426 60.571 76 54 76 C 47.429 76 42.294 75.426 38.596 74.78 C 34.165 74.006 31.282 70.133 31.128 65.649 C 31.055 63.552 31 61.335 31 59.482 C 31 57.629 31.055 55.412 31.128 53.315 C 31.282 48.831 34.165 44.957 38.596 44.183 C 41.576 43.663 45.489 43.189 50.335 43.025 C 51.232 37.348 56.145 33 62.083 33 C 68.658 33 73.977 38.331 73.977 44.895 L 73.977 46.512 Z M 52.345 42.976 C 52.886 42.968 53.438 42.963 54 42.963 L 54.086 42.963 C 53.495 42.964 52.915 42.969 52.347 42.978 C 52.224 43.601 52.16 44.244 52.16 44.902 L 52.16 51.756 L 48.489 51.76 C 46.26 51.763 44.867 54.174 45.98 56.106 L 51.541 65.764 C 52.656 67.699 55.448 67.701 56.565 65.767 L 62.15 56.095 C 63.267 54.161 61.869 51.744 59.636 51.747 L 55.803 51.752 L 55.803 44.902 L 55.803 44.895 L 55.782 44.895 C 55.782 41.413 58.603 38.59 62.083 38.59 C 65.26 38.59 67.888 40.943 68.322 44.003 C 68.695 44.062 69.056 44.122 69.404 44.183 C 70.345 44.347 71.216 44.651 72.006 45.071 L 72.006 44.895 C 72.006 39.412 67.563 34.967 62.083 34.967 C 57.259 34.967 53.239 38.411 52.345 42.976 Z M 66.248 43.705 C 65.731 41.885 64.058 40.557 62.083 40.557 C 60.356 40.557 58.86 41.571 58.166 43.043 C 61.248 43.162 63.941 43.407 66.248 43.705 Z"
|
||||
android:fillColor="#d43c3c"
|
||||
android:strokeWidth="1"
|
||||
android:fillType="evenOdd"/>
|
||||
</vector>
|
||||
5
app/src/main/res/drawable/ic_downloads.xml
Normal file
5
app/src/main/res/drawable/ic_downloads.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M19.35,10.04C18.67,6.59 15.64,4 12,4 9.11,4 6.6,5.64 5.35,8.04 2.34,8.36 0,10.91 0,14c0,3.31 2.69,6 6,6h13c2.76,0 5,-2.24 5,-5 0,-2.64 -2.05,-4.78 -4.65,-4.96zM19,18L6,18c-2.21,0 -4,-1.79 -4,-4 0,-2.05 1.53,-3.76 3.56,-3.97l1.07,-0.11 0.5,-0.95C8.08,7.14 9.94,6 12,6c2.62,0 4.88,1.86 5.39,4.43l0.3,1.5 1.53,0.11c1.56,0.1 2.78,1.41 2.78,2.96 0,1.65 -1.35,3 -3,3zM13.45,10h-2.9v3L8,13l4,4 4,-4h-2.55z"/>
|
||||
</vector>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M13,3c-4.97,0 -9,4.03 -9,9L1,12l3.89,3.89 0.07,0.14L9,12L6,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.93,0 -3.68,-0.79 -4.94,-2.06l-1.42,1.42C8.27,19.99 10.51,21 13,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9zM12,8v5l4.28,2.54 0.72,-1.21 -3.5,-2.08L13.5,8L12,8z"/>
|
||||
</vector>
|
||||
|
|
@ -1,27 +1,62 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
<RelativeLayout
|
||||
android:id="@+id/history_no_results"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/preference_coordinatorLayout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/preference_coordinatorLayout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/home_toolbar"
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:title="@string/more"
|
||||
app:menu="@menu/empty_menu"
|
||||
/>
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/home_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:title="@string/more"
|
||||
app:menu="@menu/empty_menu"
|
||||
/>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginStart="100dp"
|
||||
android:layout_marginTop="?attr/actionBarSize"
|
||||
android:layout_marginEnd="100dp"
|
||||
android:gravity="top"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="MissingConstraints">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/ic_app_icon" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/no_results"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</RelativeLayout>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,17 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/download_progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="bottom"
|
||||
android:backgroundTintMode="src_in"
|
||||
android:progress="0"
|
||||
android:alpha="0.7"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:scaleY="100" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/result_title"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -101,16 +112,6 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/download_progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="4dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:backgroundTintMode="src_in"
|
||||
android:progress="0"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:scaleY="2" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
<item android:title="@string/home"
|
||||
android:icon="@drawable/ic_home"
|
||||
android:id="@+id/home"/>
|
||||
<item android:title="@string/history"
|
||||
android:icon="@drawable/ic_history"
|
||||
android:id="@+id/history"/>
|
||||
<item android:title="@string/downloads"
|
||||
android:icon="@drawable/ic_downloads"
|
||||
android:id="@+id/downloads"/>
|
||||
<item android:title="@string/more"
|
||||
android:icon="@drawable/ic_more"
|
||||
android:id="@+id/more"/>
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@
|
|||
<string name="music_editor">Redaktori i Muzikës</string>
|
||||
<string name="cli">Komanda</string>
|
||||
<string name="more">Më Shumë</string>
|
||||
<string name="update_app">Përditëso Aplikacionin</string>
|
||||
<string name="download_latest_version">Shkarko versionin e fundit të aplikacionit</string>
|
||||
<string name="update_app">Kontrollo për përditësime</string>
|
||||
<string name="version">Versioni</string>
|
||||
<string name="custom_command">Ekzekuto Komandën</string>
|
||||
<string name="write_ytdlp_command">Shkruaj komandën yt-dlp</string>
|
||||
|
|
@ -96,4 +95,6 @@
|
|||
<string name="link_copied_to_clipboard">Linku u kopjua</string>
|
||||
<string name="api_key">Çelësi API i YouTube</string>
|
||||
<string name="api_key_summary">Përdor një çelës api për të marrë rezultate më të shpejta nga YouTube</string>
|
||||
<string name="update_app_summary">Njoftohu kur një përditësim është i vlefshëm</string>
|
||||
<string name="downloads">Shkarkimet</string>
|
||||
</resources>
|
||||
|
|
@ -45,8 +45,7 @@
|
|||
<string name="music_editor">Music Editor</string>
|
||||
<string name="cli">Commands</string>
|
||||
<string name="more">More</string>
|
||||
<string name="update_app">Update App</string>
|
||||
<string name="download_latest_version">Download the latest version of the app</string>
|
||||
<string name="update_app">Check for updates</string>
|
||||
<string name="version">Version</string>
|
||||
<string name="custom_command">Run Custom Command</string>
|
||||
<string name="write_ytdlp_command">Write yt-dlp command</string>
|
||||
|
|
@ -99,4 +98,6 @@
|
|||
<string name="link_copied_to_clipboard">Link copied to clipboard</string>
|
||||
<string name="api_key">YouTube API Key</string>
|
||||
<string name="api_key_summary">Use an api key to get faster results from YouTube</string>
|
||||
<string name="update_app_summary">Let you know when updates are available right when you open the application</string>
|
||||
<string name="downloads">Downloads</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -4,32 +4,15 @@
|
|||
<Preference
|
||||
android:layout="@layout/fragment_more"/>
|
||||
|
||||
<PreferenceCategory android:title="@string/updating">
|
||||
<Preference
|
||||
app:icon="@drawable/ic_update"
|
||||
app:key="update_ytdl"
|
||||
app:summary="@string/ytdl_update_hint"
|
||||
app:title="@string/update_ytdl" />
|
||||
|
||||
<Preference
|
||||
app:icon="@drawable/ic_update_app"
|
||||
app:key="update_app"
|
||||
app:summary="@string/download_latest_version"
|
||||
app:title="@string/update_app" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/about">
|
||||
<Preference
|
||||
app:icon="@drawable/ic_code"
|
||||
app:key="rreth"
|
||||
app:summary="https://github.com/deniscerri/ytdlnis"
|
||||
app:title="@string/source_code">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://github.com/deniscerri/ytdlnis" />
|
||||
</Preference>
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
app:icon="@drawable/ic_code"
|
||||
app:key="rreth"
|
||||
app:summary="https://github.com/deniscerri/ytdlnis"
|
||||
app:title="@string/source_code">
|
||||
<intent
|
||||
android:action="android.intent.action.VIEW"
|
||||
android:data="https://github.com/deniscerri/ytdlnis" />
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
app:icon="@drawable/ic_baseline_keyboard_arrow_right_24"
|
||||
|
|
@ -40,7 +23,6 @@
|
|||
<intent android:action="ytdlnis.page.CustomCommandActivity" />
|
||||
</Preference>
|
||||
|
||||
|
||||
<Preference
|
||||
app:icon="@drawable/ic_settings"
|
||||
app:key="open_settings"
|
||||
|
|
|
|||
|
|
@ -126,6 +126,23 @@
|
|||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
<PreferenceCategory android:title="@string/updating">
|
||||
<Preference
|
||||
app:icon="@drawable/ic_update"
|
||||
app:key="update_ytdl"
|
||||
app:summary="@string/ytdl_update_hint"
|
||||
app:title="@string/update_ytdl" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
android:icon="@drawable/ic_update_app"
|
||||
android:key="update_app"
|
||||
app:summary="@string/update_app_summary"
|
||||
app:title="@string/update_app" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<Preference
|
||||
app:allowDividerAbove="true"
|
||||
app:icon="@drawable/ic_info"
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ buildscript {
|
|||
}
|
||||
|
||||
def versionMajor = 1
|
||||
def versionMinor = 3
|
||||
def versionMinor = 2
|
||||
def versionPatch = 1
|
||||
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue