Skip to content

Commit

Permalink
cleaned up a lot of old code of the old gui.
Browse files Browse the repository at this point in the history
  • Loading branch information
LordH3lmchen committed May 28, 2015
1 parent 5487696 commit 717703b
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions .idea/artifacts/TwitchToolsCmd.xml

This file was deleted.

18 changes: 9 additions & 9 deletions .idea/artifacts/TwitchTools_jar.xml → .idea/artifacts/TwitchVodLoader_jar.xml
100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
It's a small tool to download past broadcasts from Twitch.tv. You can enter a URL to a past broadcast.

## HowTo use it:
# HowTo use it

## Windows

1. Get the compiled version (jar File)
2. Get ffmpeg https://www.ffmpeg.org/download.html
3. place both the jar and ffmpeg in the same directory
4. Start the tool
5. open settings if you want to change the quality of VODs or the destination Directory ...
2. Start the tool

Use it.
## Linux or Apple OS X
1. Install ffmpeg
2. Get the compiled version (jar File)
3. Start the tool


# Features
* Create mp4 Videos using FFMPEG
* A m3u-playlist is created to make watching the past broadcast easier.
* Support for the new TwitchVOD System, that stores the VOD in 3 second Chunks.
* Downloading Multiple Videos (Queue)
* queue for converting.
* queue for converting and downloads


# Upcoming Features

* Improved queuing of downloads
* Filter Results

# Compiled JAR
Expand Down
5 changes: 2 additions & 3 deletions TwitchTools.iml → TwitchVodLoader.iml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<content url="file://$USER_HOME$/Developer/IDEAprojects/TwitchTools">
<sourceFolder url="file://$USER_HOME$/Developer/IDEAprojects/TwitchTools/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
Expand All @@ -19,7 +19,6 @@
</library>
</orderEntry>
<orderEntry type="library" name="jgoodies-common-1.2.1" level="project" />
<orderEntry type="library" name="guava-18.0" level="project" />
<orderEntry type="library" name="com.google.code.gson:gson:2.3.1" level="project" />
<orderEntry type="library" name="com.google.guava:guava:18.0" level="project" />
</component>
Expand Down
2 changes: 1 addition & 1 deletion src/META-INF/MANIFEST.MF
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.trabauer.twitchtools.TwitchToolsApp
Main-Class: com.trabauer.twitchtools.TwitchVodLoader

Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import java.net.URISyntaxException;

/**
* Created by Flo on 12.11.2014.
* Created by Florian Trabauer on 12.11.2014. Main
*/
public class TwitchToolsApp{
public class TwitchVodLoader {


public static void main (String[] args) throws URISyntaxException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* Created by flo on 03.11.14.
*/
public class TwitchToolsCmdApp {
public class TwitchVodLoaderCmdApp {

private static final String destinationDir = "D:\\twitchStreams";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.trabauer.twitchtools.controller.channelsync;

import com.trabauer.twitchtools.TwitchToolsApp;
import com.trabauer.twitchtools.TwitchVodLoader;
import com.trabauer.twitchtools.gui.images.TwitchToolsImages;
import com.trabauer.twitchtools.gui.vod.channelsync.ChannelSyncLogFrame;
import com.trabauer.twitchtools.gui.vod.channelsync.ChannelSyncMenuBar;
import com.trabauer.twitchtools.gui.vod.channelsync.SyncChannelMainPanel;
import com.trabauer.twitchtools.model.twitch.*;
import com.trabauer.twitchtools.utils.OsUtils;
import com.trabauer.twitchtools.utils.OsValidator;
import com.trabauer.twitchtools.utils.TwitchToolPreferences;
import com.trabauer.twitchtools.worker.FFMpegConverterWorker;
import com.trabauer.twitchtools.worker.HttpFileDownloadWorker;
Expand Down Expand Up @@ -51,6 +52,7 @@ public class ChannelSyncController implements ChannelSyncControllerInterface {
private final ThreadPoolExecutor ffmpegExecutorService;
private final ThreadPoolExecutor downloadExecutorService;
private File ffmpegExecutable;
private String ffmpegCommand;
private ArrayList<TwitchVideoPart> videoParts;


Expand All @@ -66,25 +68,34 @@ public ChannelSyncController() {
mainFrame.setVisible(true);
mainFrame.setIconImage(TwitchToolsImages.getTwitchDownloadToolImage());

mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
mainMenuBar = new ChannelSyncMenuBar(this, mainFrame);

this.progressFrame = new ChannelSyncLogFrame();
this.playlistFolderPath = TwitchToolPreferences.getInstance().get(TwitchToolPreferences.DESTINATION_DIR_PREFKEY, OsUtils.getUserHome()) + "/playlists/";
this.ffmpegExecutorService = new ThreadPoolExecutor(1, 1, 5000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
this.downloadExecutorService = new ThreadPoolExecutor(15, 15, 5000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());

twitchVideoInfoWorkerQueue = new LinkedBlockingQueue<TwitchVideoInfo>();
twitchVideoInfoWorkerQueue = new LinkedBlockingQueue<>();

try { // look for ffmpeg
ffmpegExecutable = new File(new File(getJarURI().getPath()).getParent().concat("/ffmpeg.exe"));
if(! ffmpegExecutable.exists()) {
int choice = JOptionPane.showConfirmDialog(mainFrame, "FFMPEG not found! Do you wnat to download it? FFMPEG is required to convert videos", "FFMPEG not found! Download it?", JOptionPane.YES_NO_OPTION);
if(choice == 0) { //YES
downloadFFMPEG();
} else if(choice == 0) { //NO
if(OsValidator.isWindows()) {
ffmpegExecutable = new File(new File(getJarURI().getPath()).getParent().concat("/ffmpeg.exe"));
if (!ffmpegExecutable.exists()) {
int choice = JOptionPane.showConfirmDialog(mainFrame, "FFMPEG not found! Do you wnat to download it? FFMPEG is required to convert videos", "FFMPEG not found! Download it?", JOptionPane.YES_NO_OPTION);
if (choice == 0) { //YES
downloadFFMPEG();
} //else if(choice == 0) { //NO
// Nothing right now
//}
}
ffmpegCommand = ffmpegExecutable.getAbsolutePath();
} else if(OsValidator.isUnix() || OsValidator.isMac()) {
System.out.println("Running on a Unix System");
ffmpegCommand = "ffmpeg";
} else {
System.out.println("unknown OS asuming ffmpeg is installed and can be accessed via path-variable");
ffmpegCommand = "ffmpeg";
}
} catch (URISyntaxException e) {
JOptionPane.showMessageDialog(mainPanel, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
Expand All @@ -99,7 +110,7 @@ public JPanel getMainPanel() {
@Override
public void searchFldText(String text) throws IOException {

ArrayList<TwitchVideoInfo> cachedTVIs = new ArrayList<TwitchVideoInfo>();
ArrayList<TwitchVideoInfo> cachedTVIs = new ArrayList<>();


//Getting all Quued and Processed VideoInfoObjects
Expand All @@ -110,6 +121,7 @@ public void searchFldText(String text) throws IOException {
for(TwitchVideoInfo queued: twitchVideoInfoWorkerQueue.toArray(new TwitchVideoInfo[0])) {
cachedTVIs.add(queued);
}

for(Runnable runnable:ffmpegExecutorService.getQueue()) {
if(runnable instanceof FFMpegConverterWorker) {
FFMpegConverterWorker ffMpegConverterWorker = (FFMpegConverterWorker) runnable;
Expand All @@ -128,7 +140,7 @@ public void searchFldText(String text) throws IOException {
* Updates the State of a new TwitchVideoInfoObjects based on the Stored Videos
*
*
* @param tvi
* @param tvi the Twitch Video Info Object that should be modified
*/
private void searchLocalFiles(TwitchVideoInfo tvi) {
if (tvi.getState().equals(TwitchVideoInfo.State.INITIAL)) {
Expand Down Expand Up @@ -247,14 +259,13 @@ public void convert2mp4(TwitchVideoInfo relatedTwitchVideoInfoObject) {
}


FFMpegConverterWorker ffMpegConverterWorker = new FFMpegConverterWorker(destinationVideoFile, ffmpegFileListFile, ffmpegExecutable, ffmpegOptions);
FFMpegConverterWorker ffMpegConverterWorker = new FFMpegConverterWorker(destinationVideoFile, ffmpegFileListFile, ffmpegCommand, ffmpegOptions);
ffMpegConverterWorker.setVideoLength(relatedTwitchVideoInfoObject.getLength());
ffMpegConverterWorker.setRelatedTwitchVideoInfo(relatedTwitchVideoInfoObject);
ffMpegConverterWorker.addPropertyChangeListener(this);
ffMpegConverterWorker.addPropertyChangeListener(mainPanel.getConvertProgressPanel());
LinkedBlockingQueue queue = (LinkedBlockingQueue)ffmpegExecutorService.getQueue();
mainPanel.getConvertProgressPanel().setQueue(queue);
//relatedTwitchVideoInfoObject.setMainRelatedFileOnDisk(destinationVideoFile); //TODO is now done by the converter worker after converting. Testing required! This makes it possible to watch while converting
relatedTwitchVideoInfoObject.setState(TwitchVideoInfo.State.QUEUED_FOR_CONVERT);
ffmpegExecutorService.execute(ffMpegConverterWorker);
}
Expand All @@ -268,7 +279,6 @@ public void delete(TwitchVideoInfo relatedTwitchVideoInfoObject) {
/**
* Prepares the Download and creates needed files in the destination folder
*
* @throws IOException
*/
private void initializeDownload() {

Expand Down Expand Up @@ -301,7 +311,7 @@ private void initializeDownload() {
String dateTimeStr = sdf.format(currentTwitchVideoInfo.getRecordedAt().getTime());
String destinationDir = TwitchToolPreferences.getInstance().get(TwitchToolPreferences.DESTINATION_DIR_PREFKEY, OsUtils.getUserHome());
File destinationFilenameTemplate = new File(destinationDir + "/" + OsUtils.getValidFilename(currentTwitchVideoInfo.getChannelName()) + "/" + OsUtils.getValidFilename(currentTwitchVideoInfo.getTitle()) + "_" + dateTimeStr);
ArrayList<File> destinationFiles = new ArrayList<File>();
ArrayList<File> destinationFiles = new ArrayList<>();

for(TwitchVideoPart videoPart: videoParts) {
videoPart.getFileExtension();
Expand Down Expand Up @@ -414,7 +424,7 @@ private URI getJarURI()
final URL url;
final URI uri;

domain = TwitchToolsApp.class.getProtectionDomain();
domain = TwitchVodLoader.class.getProtectionDomain();
source = domain.getCodeSource();
url = source.getLocation();
uri = url.toURI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public void actionPerformed(ActionEvent e) {
}
});

JLabel helpTextLbl = new JLabel("<html>You are able to move the qualities up and down. " +
"TwitchTools trys to download the video qualities in that order. " +
"If the quality at the top isn't available, it will try to download the " +
"second, third ... and so on.</html>");


JButton okBtn = new JButton("OK");
okBtn.addActionListener(new ActionListener() {
Expand Down Expand Up @@ -147,12 +152,13 @@ public void actionPerformed(ActionEvent e) {
formPanel.add(upDownPanel, c);

c.gridy++;
formPanel.add(new JLabel("<html>You are able to move the qualities up and down. " +
"TwitchTools trys to download the video qualities in that order. " +
"If the quality at the top isn't available, it will try to download the " +
"second, third ... and so on.</html>"), c);

setSize(400, 310);

helpTextLbl.setPreferredSize(new Dimension(400,100));
formPanel.add(helpTextLbl, c);

//setSize(400, 500);
pack();



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,50 +49,6 @@ public class SyncChannelMainPanel extends JPanel implements PropertyChangeListen



public static void main(String[] args) {
// Set look & feel
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}

SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// DownloadController downloadController = new DownloadController();
// MainController mainController = MainController.getInstance();

final JFrame mainFrame = new JFrame("SyncChannelTest");
TwitchVideoInfoList twitchVideoInfoList = new TwitchVideoInfoList(); //model
ChannelSyncController controller = new ChannelSyncController(); //Controller

mainFrame.setContentPane(controller.getMainPanel()); //get the view from controller

mainFrame.pack();
mainFrame.setSize(1080, 700);
// mainFrame.addComponentListener(new ComponentAdapter() {
// @Override
// public void componentResized(ComponentEvent e) {
// System.out.println("MainFrameSiz=" + mainFrame.getSize());
//
// }
// });
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
mainFrame.setVisible(true);
}
});


}


public SyncChannelMainPanel(ChannelSyncController controller, TwitchVideoInfoList twitchVideoInfoList) {
setName("SyncChannel");
this.controller = controller;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ public void mouseClicked(MouseEvent e) {
private void layoutComponents() {

imageLbl.setBounds(0,0 ,320,180);
viewcountLbl.setBounds(5,0,100,25);
durationLbl.setBounds(255,0,100,25);
viewcountLbl.setBounds(5,0,310,25);
viewcountLbl.setHorizontalAlignment(SwingConstants.LEFT);
durationLbl.setBounds(5,0,310,25);
durationLbl.setHorizontalAlignment(SwingConstants.RIGHT);
//Adding a dark bar to the previewImage to increase the readability of the viewcount and duration
JLabel darkBarkLbl = new JLabel();
darkBarkLbl.setBounds(0,0,320,25);
Expand Down
Loading

0 comments on commit 717703b

Please sign in to comment.