This commit is contained in:
subhra74 2018-05-01 22:53:43 +02:00
parent f5bad8bb2c
commit 08745ed338
39 changed files with 226 additions and 124 deletions

View File

@ -2,8 +2,8 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="/home/subhro/Documents/XDM_DEV/lib/commons-net-3.6.jar"/>
<classpathentry kind="lib" path="/home/subhro/Documents/XDM_DEV/lib/xz-1.6.jar"/>
<classpathentry kind="lib" path="/home/subhro/Documents/XDM_DEV/lib/json-simple-1.1.1.jar"/>
<classpathentry kind="lib" path="/home/subhro/Documents/lib/xz-1.6.jar"/>
<classpathentry kind="lib" path="/home/subhro/Documents/lib/json-simple-1.1.1.jar"/>
<classpathentry kind="lib" path="/home/subhro/Documents/lib/commons-net-3.6.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -339,4 +339,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Giriş Yap
LBL_BATCH_FILE1=İlk Dosya
LBL_BATCH_FILE2=İkinci Dosya
LBL_BATCH_FILEN=Son Dosya
LBL_SHOW_PROGRESS=İlerlemeyi Göster
LBL_SHOW_PROGRESS=İlerlemeyi Göster
LBL_FILE_TYPE=File type

View File

@ -327,4 +327,5 @@ LBL_BATCH_LOGIN_DET=Login
LBL_BATCH_FILE1=First file
LBL_BATCH_FILE2=Second file
LBL_BATCH_FILEN=Last file
LBL_SHOW_PROGRESS=Show progress
LBL_SHOW_PROGRESS=Show progress
LBL_FILE_TYPE=File type

View File

@ -141,7 +141,8 @@ public class Config {
} catch (Exception e) {
}
try {
fw.close();
if (fw != null)
fw.close();
} catch (Exception e) {
}
}

View File

@ -36,7 +36,7 @@ public class CredentialManager {
}
public PasswordAuthentication getCredentialForHost(String host) {
System.out.println("Getting cred for "+host);
System.out.println("Getting cred for " + host);
PasswordAuthentication pauth = savedCredentials.get(host);
if (pauth == null) {
return cachedCredentials.get(host);
@ -47,7 +47,7 @@ public class CredentialManager {
public PasswordAuthentication getCredentialForProxy() {
if (!StringUtils.isNullOrEmptyOrBlank(Config.getInstance().getProxyUser())) {
return new PasswordAuthentication(Config.getInstance().getProxyUser(),
Config.getInstance().getProxyPass() == null ? null
Config.getInstance().getProxyPass() == null ? new char[0]
: Config.getInstance().getProxyPass().toCharArray());
} else {
return null;

View File

@ -11,9 +11,7 @@ import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import xdman.ui.res.StringResource;
@ -61,8 +59,7 @@ public class QueueManager {
private void loadQueues() {
File file = new File(Config.getInstance().getDataFolder(), "queues.txt");
DownloadQueue defaultQ = new DownloadQueue("",
StringResource.get("DEF_QUEUE"));
DownloadQueue defaultQ = new DownloadQueue("", StringResource.get("DEF_QUEUE"));
queueList.add(defaultQ);
if (!file.exists()) {
return;
@ -72,9 +69,9 @@ public class QueueManager {
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream(file), Charset.forName("UTF-8")));
int count = Integer.parseInt(reader.readLine().trim());
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")));
String str = reader.readLine();
int count = Integer.parseInt((str == null ? "0" : str).trim());
for (int i = 0; i < count; i++) {
String id = reader.readLine().trim();
String name = reader.readLine().trim();
@ -102,7 +99,8 @@ public class QueueManager {
} else {
if (Integer.parseInt(reader.readLine()) == 1) {
String ln = reader.readLine();
queue.setExecDate(dateFormatter.parse(ln));
if (ln != null)
queue.setExecDate(dateFormatter.parse(ln));
}
}
}
@ -114,7 +112,8 @@ public class QueueManager {
Logger.log(e);
}
try {
reader.close();
if (reader != null)
reader.close();
} catch (Exception e1) {
}
}
@ -126,8 +125,7 @@ public class QueueManager {
String newLine = System.getProperty("line.separator");
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
try {
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(file), Charset.forName("UTF-8")));
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), Charset.forName("UTF-8")));
writer.write(count + newLine);
for (int i = 0; i < count; i++) {
DownloadQueue queue = queueList.get(i);
@ -153,8 +151,7 @@ public class QueueManager {
} else {
if (queue.getExecDate() != null) {
writer.write("1" + newLine);
writer.write(dateFormatter.format(queue
.getExecDate()) + newLine);
writer.write(dateFormatter.format(queue.getExecDate()) + newLine);
} else {
writer.write("0" + newLine);
}

View File

@ -37,7 +37,7 @@ public class QueueScheduler implements Runnable {
try {
Calendar cal = Calendar.getInstance();
while (!stop) {
while (true) {
try {
long currentTime = System.currentTimeMillis();
if (currentTime - lastKeepAwakePing > 3000) {

View File

@ -37,6 +37,7 @@ import xdman.downloaders.metadata.HlsMetadata;
import xdman.downloaders.metadata.HttpMetadata;
import xdman.monitoring.BrowserMonitor;
import xdman.network.http.HttpContext;
import xdman.ui.components.BatchDownloadWnd;
import xdman.ui.components.ComponentInstaller;
import xdman.ui.components.DownloadCompleteWnd;
import xdman.ui.components.DownloadWindow;
@ -320,34 +321,48 @@ public class XDMApp implements DownloadListener, DownloadWindowListener, Compara
}
public void downloadUpdated(String id) {
DownloadEntry ent = downloads.get(id);
Downloader d = downloaders.get(id);
if (d == null) {
Logger.log("################# sync error ##############");
}
ent.setSize(d.getSize());
ent.setDownloaded(d.getDownloaded());
ent.setProgress(d.getProgress());
ent.setState(d.isAssembling() ? XDMConstants.ASSEMBLING : XDMConstants.DOWNLOADING);
DownloadWindow wnd = downloadWindows.get(id);
if (wnd != null) {
wnd.update(d, ent.getFile());
}
notifyListeners(id);
long now = System.currentTimeMillis();
if (now - lastSaved > 5000) {
saveDownloadList();
lastSaved = now;
try {
DownloadEntry ent = downloads.get(id);
Downloader d = downloaders.get(id);
if (d == null) {
Logger.log("################# sync error ##############");
return;
}
ent.setSize(d.getSize());
ent.setDownloaded(d.getDownloaded());
ent.setProgress(d.getProgress());
ent.setState(d.isAssembling() ? XDMConstants.ASSEMBLING : XDMConstants.DOWNLOADING);
DownloadWindow wnd = downloadWindows.get(id);
if (wnd != null) {
wnd.update(d, ent.getFile());
}
} finally {
notifyListeners(id);
long now = System.currentTimeMillis();
if (now - lastSaved > 5000) {
saveDownloadList();
lastSaved = now;
}
}
}
public static XDMApp getInstance() {
public synchronized static XDMApp getInstance() {
if (_this == null) {
_this = new XDMApp();
}
return _this;
}
public void addLinks(final List<HttpMetadata> list) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
BatchDownloadWnd wnd = new BatchDownloadWnd(list);
wnd.setVisible(true);
}
});
}
public void addDownload(final HttpMetadata metadata, final String file) {
if (refreshCallback != null) {
if (refreshCallback.isValidLink(metadata)) {
@ -708,6 +723,9 @@ public class XDMApp implements DownloadListener, DownloadWindowListener, Compara
DownloadEntry ent = new DownloadEntry();
for (int j = 0; j < fieldCount; j++) {
String ln = reader.readLine();
if (ln == null) {
return;
}
int index = ln.indexOf(":");
if (index > 0) {
String key = ln.substring(0, index).trim();
@ -758,7 +776,8 @@ public class XDMApp implements DownloadListener, DownloadWindowListener, Compara
Logger.log(e);
}
try {
reader.close();
if (reader != null)
reader.close();
} catch (Exception e1) {
}
}
@ -821,7 +840,8 @@ public class XDMApp implements DownloadListener, DownloadWindowListener, Compara
} catch (Exception e) {
Logger.log(e);
try {
writer.close();
if (writer != null)
writer.close();
} catch (Exception e1) {
}
}

View File

@ -65,11 +65,13 @@ public abstract class AbstractChannel implements Runnable {
close();
break;
}
chunk.transferInitiated();
// do not proceed if chunk is stoppped
if (chunk == null) {
continue;
}
chunk.transferInitiated();
if (((chunk.getLength() > 0) ? copyStream1() : copyStream2())) {
Logger.log("Copy Stream finished");
break;

View File

@ -193,9 +193,12 @@ public abstract class Downloader implements SegmentListener {
public void cleanup() {
File dir = new File(folder);
File[] files = dir.listFiles();
for (int i = 0; i < files.length; i++) {
Logger.log("Delete: " + files[i] + " [" + files[i].length() + "] " + files[i].delete());
if (files != null) {
for (int i = 0; i < files.length; i++) {
Logger.log("Delete: " + files[i] + " [" + files[i].length() + "] " + files[i].delete());
}
}
new File(folder).delete();
}
@ -276,9 +279,9 @@ public abstract class Downloader implements SegmentListener {
System.out.println("setting date");
Date lastModified = HttpDateParser.parseHttpDate(this.lastModified);
if (lastModified != null) {
System.out.println("setting date file "+lastModified);
boolean val=outFile.setLastModified(lastModified.getTime());
System.out.println("rename: "+val+new Date(outFile.lastModified()));
System.out.println("setting date file " + lastModified);
boolean val = outFile.setLastModified(lastModified.getTime());
System.out.println("rename: " + val + new Date(outFile.lastModified()));
}
} catch (Exception e) {
Logger.log(e);

View File

@ -14,7 +14,7 @@ public class SegmentDetails {
return segInfoList;
}
public final long getChunkCount() {
public synchronized final long getChunkCount() {
return chunkCount;
}

View File

@ -97,6 +97,7 @@ public class DashDownloader extends Downloader implements SegmentListener, Media
Segment c = getById(id);
if (c == null) {
Logger.log(id + " is no longer valid chunk");
return;
}
// int code = dc.getCode();
// Logger.log(id + " code: " + code + " len: " + c.getLength());
@ -119,10 +120,10 @@ public class DashDownloader extends Downloader implements SegmentListener, Media
System.out.println("this.len1: " + this.len1 + " this.len2: " + this.len2);
}
if (c.getTag().equals("T1") && this.len1 > 0) {
if ("T1".equals(c.getTag()) && this.len1 > 0) {
createChunk();
}
if (c.getTag().equals("T2") && this.len2 > 0) {
if ("T2".equals(c.getTag()) && this.len2 > 0) {
createChunk();
}
}
@ -329,7 +330,7 @@ public class DashDownloader extends Downloader implements SegmentListener, Media
long timeSpend = now - prevTime;
if (timeSpend > 0) {
float rate = ((float) diff / timeSpend) * 1000;
//downloadSpeed = rate;
// downloadSpeed = rate;
this.eta = FormatUtilities.getETA(length - downloaded, rate);
if (this.eta == null) {
this.eta = "---";
@ -543,7 +544,7 @@ public class DashDownloader extends Downloader implements SegmentListener, Media
}
private void saveState() {
if (chunks.size() < 0)
if (chunks.size() < 1)
return;
StringBuffer sb = new StringBuffer();
sb.append(this.length + "\n");

View File

@ -395,7 +395,7 @@ public class HdsDownloader extends Downloader implements SegmentListener, MediaC
}
private void saveState() {
if (chunks.size() < 0)
if (chunks.size() < 1)
return;
StringBuffer sb = new StringBuffer();
sb.append(this.length + "\n");

View File

@ -335,8 +335,8 @@ public class HlsDownloader extends Downloader implements SegmentListener, MediaC
long diff = downloaded - lastDownloaded;
long timeSpend = now - prevTime;
if (timeSpend > 0) {
//float rate = ((float) diff / timeSpend) * 1000;
//downloadSpeed = rate;
// float rate = ((float) diff / timeSpend) * 1000;
// downloadSpeed = rate;
int prgDiff = progress - lastProgress;
if (prgDiff > 0) {
@ -421,7 +421,7 @@ public class HlsDownloader extends Downloader implements SegmentListener, MediaC
}
private void saveState() {
if (chunks.size() < 0)
if (chunks.size() < 1)
return;
StringBuffer sb = new StringBuffer();
sb.append(this.length + "\n");

View File

@ -512,7 +512,7 @@ public class F4MManifest {
Segment segEntry = new Segment();
segEntry.firstSegment = firstSegment;
segEntry.fragmentsPerSegment = (int) readInt32(asrt, pos + 4);
if ((segEntry.fragmentsPerSegment & 0x80000000) > 0)
if ((segEntry.fragmentsPerSegment & 0x80000000L) > 0)
segEntry.fragmentsPerSegment = 0;
pos += 8;
segTable.add(segEntry);

View File

@ -1,14 +1,11 @@
package xdman.monitoring;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.Socket;
import java.net.URL;
import java.net.URLDecoder;
@ -21,19 +18,13 @@ import xdman.Config;
import xdman.XDMApp;
import xdman.XDMConstants;
import xdman.downloaders.metadata.DashMetadata;
import xdman.downloaders.metadata.HdsMetadata;
import xdman.downloaders.metadata.HlsMetadata;
import xdman.downloaders.metadata.HttpMetadata;
import xdman.downloaders.metadata.manifests.M3U8Manifest;
import xdman.downloaders.metadata.manifests.M3U8Manifest.M3U8MediaInfo;
import xdman.network.ProxyResolver;
import xdman.network.http.HeaderCollection;
import xdman.network.http.HttpHeader;
import xdman.network.http.JavaHttpClient;
import xdman.network.http.WebProxy;
import xdman.preview.FFmpegStream;
import xdman.preview.PreviewStream;
import xdman.ui.res.StringResource;
import xdman.util.FormatUtilities;
import xdman.util.Logger;
import xdman.util.StringUtils;
@ -93,9 +84,16 @@ public class MonitoringSession implements Runnable {
Logger.log(new String(request.getBody()));
byte[] b = request.getBody();
List<ParsedHookData> list = ParsedHookData.parseLinks(b);
List<HttpMetadata> metadatas = new ArrayList<>();
for (ParsedHookData d : list) {
System.out.println(d);
HttpMetadata md = new HttpMetadata();
md.setUrl(d.getUrl());
md.setHeaders(d.getRequestHeaders());
metadatas.add(md);
}
XDMApp.getInstance().addLinks(metadatas);
// ParsedHookData data = ParsedHookData.parse(b);
// if (data.getUrl() != null && data.getUrl().length() > 0) {
// HttpMetadata metadata = new HttpMetadata();

View File

@ -72,7 +72,7 @@ public class ParsedHookData {
if (index > 0) {
String cookieName = val.substring(0, index).trim();
String cookieValue = val.substring(index + 1).trim();
System.out.println("********Adding cookie " + val);
//System.out.println("********Adding cookie " + val);
data.requestHeaders.addHeader("cookie", cookieName + "=" + cookieValue);
}
}

View File

@ -17,7 +17,7 @@ public class Response {
buf.append("HTTP/1.1 " + code + " " + message + "\r\n");
if (body != null) {
if (code != 204) {
headers.addHeader("Content-Length", (body == null || body.length < 0) ? "0" : body.length + "");
headers.addHeader("Content-Length", (body == null || body.length < 1) ? "0" : body.length + "");
}
headers.appendToBuffer(buf);
}

View File

@ -84,17 +84,9 @@ public class YtUtil {
}
}
static HashMap<Integer, String> itags;
public static String getInfoFromITAG(int itag) {
loadITAGs();
return (String) itags.get(itag);
}
static void loadITAGs() {
if (itags != null) {
return;
}
private static HashMap<Integer, String> itags;
static {
itags = new HashMap<Integer, String>();
itags.put(5, "240p");
itags.put(6, "270p");
@ -156,6 +148,11 @@ public class YtUtil {
itags.put(313, "2160p");
itags.put(315, "2160p");
itags.put(299, "2160p");
}
public static String getInfoFromITAG(int itag) {
return (String) itags.get(itag);
}
}

View File

@ -11,7 +11,9 @@ import java.awt.event.MouseEvent;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListModel;
@ -53,6 +55,10 @@ public class BatchDownloadWnd extends JFrame implements ActionListener {
DefaultComboBoxModel<DownloadQueue> queueModel;
JComboBox<DownloadQueue> cmbQueues;
JCheckBox chkStartQueue;
Set<String> fileExts;
DefaultComboBoxModel<String> filterModel;
JComboBox<String> cmbFilter;
BatchItem[] items;
public static List<String> getUrls() {
List<String> urls = new ArrayList<>();
@ -73,23 +79,35 @@ public class BatchDownloadWnd extends JFrame implements ActionListener {
return urls;
}
public BatchDownloadWnd(List<String> urls) {
model = new DefaultListModel<>();
list = new JList<>(model);
public BatchDownloadWnd(List<HttpMetadata> mdList) {
fileExts = new HashSet<>();
items = new BatchItem[mdList.size()];
initUI();
for (int i = 0; i < urls.size(); i++) {
String url = urls.get(i);
for (int i = 0; i < mdList.size(); i++) {
HttpMetadata md = mdList.get(i);
try {
String file = XDMUtils.getFileName(url);
String file = XDMUtils.getFileName(md.getUrl());
BatchItem item = new BatchItem();
item.file = file;
item.selected = true;
item.url = url;
item.metadata = md;
items[i] = item;
model.addElement(item);
String ext = XDMUtils.getExtension(file);
if (!StringUtils.isNullOrEmptyOrBlank(ext)) {
fileExts.add(ext);
System.out.println("adding ext: " + ext);
}
} catch (Exception e) {
}
}
for (String ext : fileExts) {
filterModel.addElement(ext);
}
filterModel.insertElementAt("All files", 0);
cmbFilter.setSelectedIndex(0);
}
@Override
@ -124,9 +142,7 @@ public class BatchDownloadWnd extends JFrame implements ActionListener {
BatchItem item = model.getElementAt(i);
if (item.selected) {
String file = item.file;
String url = item.url;
HttpMetadata metadata = new HttpMetadata();
metadata.setUrl(url);
HttpMetadata metadata = item.metadata;
folder = txtFile.getText();
XDMApp.getInstance().createDownload(file, folder, metadata, false, q == null ? "" : q.getQueueId(), 0,
0);
@ -135,6 +151,10 @@ public class BatchDownloadWnd extends JFrame implements ActionListener {
}
private void initUI() {
model = new DefaultListModel<>();
list = new JList<>(model);
setUndecorated(true);
try {
@ -184,7 +204,8 @@ public class BatchDownloadWnd extends JFrame implements ActionListener {
add(titlePanel);
int y = getScaledInt(55);
int h = getScaledInt(420) - getScaledInt(100) - getScaledInt(70);
int h = getScaledInt(420) - getScaledInt(100) - getScaledInt(70) - getScaledInt(20);
// y += getScaledInt(40);
list.setBorder(null);
list.setOpaque(false);
@ -207,7 +228,46 @@ public class BatchDownloadWnd extends JFrame implements ActionListener {
lineLbl2.setOpaque(true);
add(lineLbl2);
y += getScaledInt(10);
y += getScaledInt(5);
// y += getScaledInt(15);
// LBL_FILE_TYPE
JLabel lblFileTypes = new JLabel(StringResource.get("LBL_FILE_TYPE"), JLabel.RIGHT);
lblFileTypes.setFont(FontResource.getNormalFont());
lblFileTypes.setForeground(Color.WHITE);
lblFileTypes.setBounds(0, y, getScaledInt(80), getScaledInt(30));
add(lblFileTypes);
filterModel = new DefaultComboBoxModel<>();
cmbFilter = new JComboBox<>(filterModel);
cmbFilter.setRenderer(new SimpleListRenderer());
cmbFilter.setBounds(getScaledInt(90), y + getScaledInt(5),
getScaledInt(305) - getScaledInt(15) + getScaledInt(50), getScaledInt(20));
add(cmbFilter);
cmbFilter.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
model.removeAllElements();
for (BatchItem item : items) {
boolean add = true;
if (cmbFilter.getSelectedIndex() > 0) {
String ext = (String) cmbFilter.getSelectedItem();
add = item.file.endsWith(ext);
}
if (add) {
model.addElement(item);
}
}
}
});
y += getScaledInt(25);
// y += getScaledInt(40);
JLabel lblFile = new JLabel(StringResource.get("LBL_SAVE_IN"), JLabel.RIGHT);
lblFile.setFont(FontResource.getNormalFont());
@ -309,9 +369,9 @@ public class BatchDownloadWnd extends JFrame implements ActionListener {
}
class BatchItem {
String url;
String file;
boolean selected;
HttpMetadata metadata;
@Override
public String toString() {

View File

@ -38,11 +38,13 @@ import javax.swing.event.DocumentListener;
import xdman.Config;
import xdman.CredentialManager;
import xdman.downloaders.metadata.HttpMetadata;
import xdman.ui.res.ColorResource;
import xdman.ui.res.FontResource;
import xdman.ui.res.ImageResource;
import xdman.ui.res.StringResource;
import xdman.util.Logger;
import xdman.util.XDMUtils;
public class BatchPatternDialog extends JFrame implements ActionListener, DocumentListener, ChangeListener {
/**
@ -399,7 +401,7 @@ public class BatchPatternDialog extends JFrame implements ActionListener, Docume
}
if (urls.size() > 0) {
dispose();
new BatchDownloadWnd(urls).setVisible(true);
new BatchDownloadWnd(XDMUtils.toMetadata(urls)).setVisible(true);
}
} catch (Exception e2) {
Logger.log(e2);

View File

@ -82,7 +82,6 @@ public class MainWindow extends XDMFrame implements ActionListener {
DownloadListView lv;
JPopupMenu popupCtx;
JMenu startQMenu, stopQMenu, convertMenu;
Container warningPanel;
JPanel toolbar;
UpdateNotifyPanel updateNotifyPanel;
@ -126,9 +125,6 @@ public class MainWindow extends XDMFrame implements ActionListener {
if (name.startsWith("STOP")) {
stopQueue(name);
} else if (name.equals("OPT_UPDATE_FFMPEG")) {
if (warningPanel != null) {
warningPanel.setVisible(false);
}
updateFFmpeg();
} else if (name.startsWith("OPT_CONVERT")) {
convert();
@ -792,7 +788,7 @@ public class MainWindow extends XDMFrame implements ActionListener {
sortStatusText[3][1] = StringResource.get("SORT_TYPE_ASC");
// test ui
setMenuActionListener(this);
//setMenuActionListener(this);
lv = new DownloadListView(panCenter);
filter();
@ -1230,7 +1226,7 @@ public class MainWindow extends XDMFrame implements ActionListener {
private void showBatchDialog() {
List<String> urlList = BatchDownloadWnd.getUrls();
if (urlList.size() > 0) {
new BatchDownloadWnd(urlList).setVisible(true);
new BatchDownloadWnd(XDMUtils.toMetadata(urlList)).setVisible(true);
} else {
MessageBox.show(this, StringResource.get("MENU_BATCH_DOWNLOAD"),
StringResource.get("LBL_BATCH_EMPTY_CLIPBOARD"), MessageBox.OK_OPTION, MessageBox.OK);

View File

@ -588,7 +588,7 @@ public class SettingsPage extends JPanel implements ActionListener, ListSelectio
y += getScaledInt(10);
h = getScaledInt(30);
panel.setPreferredSize(new Dimension(getScaledInt(300), y + getScaledInt(50)));
// panel.setMinimumSize(new Dimension(300, 700));
return panel;

View File

@ -35,8 +35,10 @@ public class SimpleCheckboxRender extends JCheckBox implements ListCellRenderer<
} else {
setBackground(ColorResource.getDarkerBgColor());
}
setSelected(((BatchItem) value).selected);
setText(value == null ? "" : value.toString());
if (value != null) {
setSelected(((BatchItem) value).selected);
setText(value == null ? "" : value.toString());
}
return this;
}

View File

@ -82,7 +82,7 @@ public class TrayHandler {
} else if ("ADD_CLIP".equals(name)) {
List<String> urlList = BatchDownloadWnd.getUrls();
if (urlList.size() > 0) {
new BatchDownloadWnd(urlList).setVisible(true);
new BatchDownloadWnd(XDMUtils.toMetadata(urlList)).setVisible(true);
} else {
JOptionPane.showMessageDialog(null, StringResource.get("LBL_BATCH_EMPTY_CLIPBOARD"));
}

View File

@ -43,7 +43,7 @@ public class XDMFrame extends JFrame implements ComponentListener {
private boolean maximizeBox = true, minimizeBox = true;
private JButton menuBtn;
//private JButton menuBtn;
private JPanel contentPane, modalPane, dialogPane;
@ -355,11 +355,11 @@ public class XDMFrame extends JFrame implements ComponentListener {
return btn;
}
protected void setMenuActionListener(ActionListener a) {
if (menuBtn != null) {
menuBtn.addActionListener(a);
}
}
// protected void setMenuActionListener(ActionListener a) {
// if (menuBtn != null) {
// menuBtn.addActionListener(a);
// }
// }
@Override
public void componentHidden(ComponentEvent c) {

View File

@ -14,7 +14,7 @@ public class StringResource {
// each file must have name like de.deutsch.german.txt
public static String get(String id) {
public synchronized static String get(String id) {
if (strings == null) {
try {
strings = new Properties();

View File

@ -9,7 +9,7 @@ import java.util.TimeZone;
public class HttpDateParser {
private static SimpleDateFormat fmt;
public static Date parseHttpDate(String lastModified) {
public synchronized static Date parseHttpDate(String lastModified) {
if (StringUtils.isNullOrEmptyOrBlank(lastModified)) {
return null;
}

View File

@ -28,6 +28,7 @@ import xdman.Config;
import xdman.Main;
import xdman.XDMApp;
import xdman.XDMConstants;
import xdman.downloaders.metadata.HttpMetadata;
public class XDMUtils {
// private static Map<Integer, String> categoryFolderMap;
@ -230,7 +231,7 @@ public class XDMUtils {
public static final int detectOS() {
String os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
if (os.contains("mac") || os.contains("darwin") || os.contains("os x") || os.contains("os x")) {
if (os.contains("mac") || os.contains("darwin") || os.contains("os x") ) {
return MAC;
} else if (os.contains("linux")) {
return LINUX;
@ -499,6 +500,16 @@ public class XDMUtils {
}
return screenType;
}
public static List<HttpMetadata> toMetadata(List<String> urls) {
List<HttpMetadata> list = new ArrayList<>();
for (String url : urls) {
HttpMetadata md = new HttpMetadata();
md.setUrl(url);
list.add(md);
}
return list;
}
private static int screenType = -1;