diff --git a/src/main/java/com/tonikelope/megabasterd/AboutDialog.java b/src/main/java/com/tonikelope/megabasterd/AboutDialog.java
index e9548b0f7..fbdd36348 100644
--- a/src/main/java/com/tonikelope/megabasterd/AboutDialog.java
+++ b/src/main/java/com/tonikelope/megabasterd/AboutDialog.java
@@ -13,10 +13,10 @@ import java.awt.Color;
public final class AboutDialog extends javax.swing.JDialog {
private static final String MEGA_URL = "https://mega.nz/#F!lYsRWaQB!uVhntmyKcVECRaOxAbcL4A";
- private static final String TONIKELOPE_URL = "http://toni.world";
+ private static final String TONIKELOPE_URL = "https://github.com/tonikelope/";
private static final String MEGACRYPTER_URL = "https://tonikelope.github.io/megacrypter/";
private static final String SPAIN_URL = "https://en.wikipedia.org/wiki/Spain";
- private static final String MEGABASTERD_GITHUB_URL = "https://github.com/tonikelope/megabasterd";
+ private static final String MEGABASTERD_GITHUB_URL = "https://github.com/tonikelope/megabasterd/";
public AboutDialog(MainPanelView parent, boolean modal) {
diff --git a/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.form b/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.form
new file mode 100644
index 000000000..4602d2831
--- /dev/null
+++ b/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.form
@@ -0,0 +1,176 @@
+
+
+
diff --git a/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java b/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java
new file mode 100644
index 000000000..65e17510c
--- /dev/null
+++ b/src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java
@@ -0,0 +1,372 @@
+/*
+ * Copyright (C) 2018 tonikelope
+ *
+ * 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 .
+ */
+package com.tonikelope.megabasterd;
+
+import static com.tonikelope.megabasterd.MainPanel.DEFAULT_FONT;
+import static com.tonikelope.megabasterd.MainPanel.THREAD_POOL;
+import static com.tonikelope.megabasterd.MiscTools.swingInvoke;
+import static com.tonikelope.megabasterd.MiscTools.updateFonts;
+import java.awt.Dialog;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import static java.lang.Integer.MAX_VALUE;
+import java.nio.channels.FileChannel;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.JFileChooser;
+import javax.swing.JOptionPane;
+
+/**
+ *
+ * @author tonikelope
+ */
+public class FileSplitterDialog extends javax.swing.JDialog {
+
+ private final MainPanelView _mainPanelView;
+ private final MainPanel _main_panel;
+ private File _file = null;
+ private File _output_dir = null;
+ private long _progress = 0L;
+
+ /**
+ * Creates new form FileSplitterDialog
+ */
+ public FileSplitterDialog(MainPanelView parent, boolean modal) {
+ super(parent, modal);
+ _main_panel = parent.getMain_panel();
+ initComponents();
+ updateFonts(this.getRootPane(), DEFAULT_FONT, _main_panel.getZoom_factor());
+ _mainPanelView = parent;
+ }
+
+ private List _splitFile() throws IOException {
+
+ int mBperSplit = Integer.parseInt(this.split_size_text.getText());
+
+ if (mBperSplit <= 0) {
+ throw new IllegalArgumentException("mBperSplit must be more than zero");
+ }
+
+ List partFiles = new ArrayList<>();
+ final long sourceSize = Files.size(Paths.get(this._file.getAbsolutePath()));
+ final long bytesPerSplit = 1024L * 1024L * mBperSplit;
+ final long numSplits = sourceSize / bytesPerSplit;
+ final long remainingBytes = sourceSize % bytesPerSplit;
+ int position = 0;
+ int conta_split = 1;
+
+ try (RandomAccessFile sourceFile = new RandomAccessFile(this._file.getAbsolutePath(), "r");
+ FileChannel sourceChannel = sourceFile.getChannel()) {
+
+ for (; position < numSplits; position++, conta_split++) {
+ _writePartToFile(bytesPerSplit, position * bytesPerSplit, sourceChannel, partFiles, conta_split);
+ }
+
+ if (remainingBytes > 0) {
+ _writePartToFile(remainingBytes, position * bytesPerSplit, sourceChannel, partFiles, conta_split);
+ }
+ }
+ return partFiles;
+ }
+
+ private void _writePartToFile(long byteSize, long position, FileChannel sourceChannel, List partFiles, int conta_split) throws IOException {
+
+ Path fileName = Paths.get(this._output_dir.getAbsolutePath() + "/" + this._file.getName() + ".part" + String.valueOf(conta_split));
+ try (RandomAccessFile toFile = new RandomAccessFile(fileName.toFile(), "rw");
+ FileChannel toChannel = toFile.getChannel()) {
+ sourceChannel.position(position);
+ toChannel.transferFrom(sourceChannel, 0, byteSize);
+ }
+ partFiles.add(fileName);
+
+ this._progress += byteSize;
+
+ swingInvoke(
+ new Runnable() {
+ @Override
+ public void run() {
+
+ jProgressBar2.setValue((int) Math.ceil((MAX_VALUE / (double) _file.length()) * _progress));
+ }
+ });
+
+ }
+
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ file_button = new javax.swing.JButton();
+ file_name_label = new javax.swing.JLabel();
+ output_button = new javax.swing.JButton();
+ file_size_label = new javax.swing.JLabel();
+ output_folder_label = new javax.swing.JLabel();
+ split_size_label = new javax.swing.JLabel();
+ split_size_text = new javax.swing.JTextField();
+ jProgressBar2 = new javax.swing.JProgressBar();
+ split_button = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("File Splitter");
+
+ file_button.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
+ file_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-add-file-30.png"))); // NOI18N
+ file_button.setText("Open file");
+ file_button.setDoubleBuffered(true);
+ file_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ file_buttonActionPerformed(evt);
+ }
+ });
+
+ file_name_label.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
+ file_name_label.setDoubleBuffered(true);
+
+ output_button.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
+ output_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-add-folder-30.png"))); // NOI18N
+ output_button.setText("Change output folder");
+ output_button.setDoubleBuffered(true);
+ output_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ output_buttonActionPerformed(evt);
+ }
+ });
+
+ file_size_label.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
+ file_size_label.setDoubleBuffered(true);
+
+ output_folder_label.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
+ output_folder_label.setDoubleBuffered(true);
+
+ split_size_label.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
+ split_size_label.setText("Split size (MBs):");
+ split_size_label.setDoubleBuffered(true);
+
+ split_size_text.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
+ split_size_text.setDoubleBuffered(true);
+
+ jProgressBar2.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
+ jProgressBar2.setDoubleBuffered(true);
+
+ split_button.setBackground(new java.awt.Color(102, 204, 255));
+ split_button.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
+ split_button.setForeground(new java.awt.Color(255, 255, 255));
+ split_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-cut-30.png"))); // NOI18N
+ split_button.setText("SPLIT FILE");
+ split_button.setDoubleBuffered(true);
+ split_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ split_buttonActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(file_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(file_name_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(output_button, javax.swing.GroupLayout.DEFAULT_SIZE, 976, Short.MAX_VALUE)
+ .addComponent(file_size_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(output_folder_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jProgressBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(split_size_label)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(split_size_text))
+ .addComponent(split_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(file_button)
+ .addGap(9, 9, 9)
+ .addComponent(file_name_label)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(file_size_label)
+ .addGap(18, 18, 18)
+ .addComponent(output_button)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(output_folder_label)
+ .addGap(18, 18, 18)
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(split_size_label)
+ .addComponent(split_size_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addComponent(jProgressBar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addComponent(split_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addContainerGap())
+ );
+
+ pack();
+ }// //GEN-END:initComponents
+
+ private void file_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_file_buttonActionPerformed
+ // TODO add your handling code here:
+
+ this.file_button.setText("Opening file...");
+
+ this.file_button.setEnabled(false);
+
+ this.output_button.setEnabled(false);
+
+ this.split_button.setEnabled(false);
+
+ JFileChooser filechooser = new javax.swing.JFileChooser();
+
+ filechooser.setDialogTitle("Add files");
+
+ filechooser.setAcceptAllFileFilterUsed(false);
+
+ if (filechooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION && filechooser.getSelectedFile().canRead()) {
+
+ this._file = filechooser.getSelectedFile();
+ this.file_name_label.setText(this._file.getAbsolutePath());
+ this.file_size_label.setText(MiscTools.formatBytes(this._file.length()));
+ this.output_folder_label.setText(this._file.getParentFile().getAbsolutePath());
+ this.jProgressBar2.setMinimum(0);
+ this.jProgressBar2.setMaximum(MAX_VALUE);
+ this.jProgressBar2.setStringPainted(true);
+ this.jProgressBar2.setValue(0);
+ this._progress = 0L;
+ }
+
+ this.file_button.setText("Open file");
+
+ this.file_button.setEnabled(true);
+
+ this.output_button.setEnabled(true);
+
+ this.split_button.setEnabled(true);
+
+ pack();
+
+ }//GEN-LAST:event_file_buttonActionPerformed
+
+ private void output_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_output_buttonActionPerformed
+ // TODO add your handling code here:
+
+ this.output_button.setText("Changing output folder...");
+
+ this.file_button.setEnabled(false);
+
+ this.output_button.setEnabled(false);
+
+ this.split_button.setEnabled(false);
+
+ JFileChooser filechooser = new javax.swing.JFileChooser();
+
+ filechooser.setDialogTitle("Add directory");
+
+ filechooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
+
+ filechooser.setAcceptAllFileFilterUsed(false);
+
+ if (filechooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION && filechooser.getSelectedFile().canRead()) {
+
+ this._output_dir = filechooser.getSelectedFile();
+
+ this.output_folder_label.setText(this._output_dir.getAbsolutePath());
+ }
+
+ this.output_button.setText("Change output folder");
+
+ this.file_button.setEnabled(true);
+
+ this.output_button.setEnabled(true);
+
+ this.split_button.setEnabled(true);
+
+ pack();
+ }//GEN-LAST:event_output_buttonActionPerformed
+
+ private void split_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_split_buttonActionPerformed
+ // TODO add your handling code here:
+
+ if (this._file != null && this._output_dir != null && !this.split_size_text.getText().equals("")) {
+
+ this.split_button.setText("SPLITTING FILE...");
+
+ this.file_button.setEnabled(false);
+
+ this.output_button.setEnabled(false);
+
+ this.split_button.setEnabled(false);
+
+ this.split_size_text.setEnabled(false);
+
+ Dialog tthis = this;
+
+ THREAD_POOL.execute(new Runnable() {
+ @Override
+ public void run() {
+
+ try {
+ _splitFile();
+ } catch (IOException ex) {
+ Logger.getLogger(FileSplitterDialog.class.getName()).log(Level.SEVERE, null, ex);
+ }
+
+ JOptionPane.showMessageDialog(tthis, "File successfully splitted!");
+
+ split_button.setText("SPLIT FILE");
+
+ file_button.setEnabled(true);
+
+ output_button.setEnabled(true);
+
+ split_button.setEnabled(true);
+
+ split_size_text.setEnabled(true);
+
+ pack();
+
+ }
+ });
+
+ }
+ }//GEN-LAST:event_split_buttonActionPerformed
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton file_button;
+ private javax.swing.JLabel file_name_label;
+ private javax.swing.JLabel file_size_label;
+ private javax.swing.JProgressBar jProgressBar2;
+ private javax.swing.JButton output_button;
+ private javax.swing.JLabel output_folder_label;
+ private javax.swing.JButton split_button;
+ private javax.swing.JLabel split_size_label;
+ private javax.swing.JTextField split_size_text;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/src/main/java/com/tonikelope/megabasterd/KissVideoStreamServer.java b/src/main/java/com/tonikelope/megabasterd/KissVideoStreamServer.java
index b66c20162..d82a01064 100644
--- a/src/main/java/com/tonikelope/megabasterd/KissVideoStreamServer.java
+++ b/src/main/java/com/tonikelope/megabasterd/KissVideoStreamServer.java
@@ -37,7 +37,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
public static final int THREAD_START = 0x01;
public static final int THREAD_STOP = 0x02;
- public static final int DEFAULT_WORKERS = 10;
+ public static final int DEFAULT_WORKERS = 8;
private final MainPanel _main_panel;
private final ConcurrentHashMap> _link_cache;
diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanel.java b/src/main/java/com/tonikelope/megabasterd/MainPanel.java
index e5e907e25..be513b4dd 100644
--- a/src/main/java/com/tonikelope/megabasterd/MainPanel.java
+++ b/src/main/java/com/tonikelope/megabasterd/MainPanel.java
@@ -48,7 +48,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
*/
public final class MainPanel {
- public static final String VERSION = "4.2";
+ public static final String VERSION = "4.3";
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
public static final int STREAMER_PORT = 1337;
diff --git a/src/main/java/com/tonikelope/megabasterd/MainPanelView.form b/src/main/java/com/tonikelope/megabasterd/MainPanelView.form
index 4047ba5f4..388339e49 100644
--- a/src/main/java/com/tonikelope/megabasterd/MainPanelView.form
+++ b/src/main/java/com/tonikelope/megabasterd/MainPanelView.form
@@ -55,6 +55,20 @@
+