I implemented a quick hack to download TV shows to separate folders based on the series name and season (e.g. /Lost S05/). This allows programs like Transmission to automatically download the videos there (trashes the torrent once it's finished as well). This suggestion covers one of the requested features(download show torrents to separate folders).
Then media center applications like XBMC, boxee, or plex can easily catalog the videos and add meta information etc.
I want to take it a step further and provide configuration options for each show you are watching (by default it could download to "${BaseDownloadDir}/${SeriesName} ${SeasonNumber#}/ShowTorrent.torrent" (/Users/ddaniels/TV/Lost S05/Lost_S05_E01.torrent).
I attached the SVN patch that hacks in the file name you can see the changed
TedIO.java here
SVN patch:
Code:
### Eclipse Workspace Patch 1.0
#P TED
Index: ted/TedParser.java
===================================================================
--- ted/TedParser.java (revision 661)
+++ ted/TedParser.java (working copy)
@@ -1044,7 +1044,7 @@
TedIO tio = new TedIO();
try
{
- tio.downloadTorrent(this.bestTorrentUrl, fileName);
+ tio.downloadTorrent(this.bestTorrentUrl, fileName, serie);
}
catch (Exception e)
{
@@ -1116,7 +1116,7 @@
TedIO tio = new TedIO();
try
{
- tio.downloadTorrent(this.bestTorrentUrl, fileName);
+ tio.downloadTorrent(this.bestTorrentUrl, fileName, serie);
}
catch (Exception e)
{
Index: ted/TedIO.java
===================================================================
--- ted/TedIO.java (revision 661)
+++ ted/TedIO.java (working copy)
@@ -790,10 +790,11 @@
* torrentclient if user wants to
* url URL of torrent to download
* name FileName to save torrent to (without directory)
+ * serie
* config TedConfig containing usersettings
* Exception
*/
- public void downloadTorrent(URL url, String name) throws Exception
+ public void downloadTorrent(URL url, String name, TedSerie serie) throws Exception
{
try
{
@@ -803,16 +804,28 @@
// opening the torrent
name = name.replaceAll("[/:&*?|\"\\\\]", "");
name = name.replaceAll(" ()", ".");
-
+ int season = serie.getCurrentSeason();
+ //generate a season prefix like S02 or S12
+ String seasonNumberSuffix = " S"+ (season<10?"0"+season:season);
//create output torrent file
- String loc = TedConfig.getDirectory() + File.separator + name + ".torrent"; //$NON-NLS-1$
+ String baseDir = TedConfig.getDirectory() + File.separator + serie.getName() + seasonNumberSuffix + File.separator;
+ File baseDirectory = new File(baseDir);
+ if (!baseDirectory.exists()) {
+ try {
+ baseDirectory.mkdir();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ String loc = baseDir + name + ".torrent"; //$NON-NLS-1$
File outputFile = new File(loc);
//file already exists
int i = 1;
while(outputFile.exists())
{
- loc = TedConfig.getDirectory() + File.separator + name + "-" + i + ".torrent"; //$NON-NLS-1$ //$NON-NLS-2$
+ loc = baseDir + name + "-" + i + ".torrent"; //$NON-NLS-1$ //$NON-NLS-2$
outputFile = new File(loc);
i++;
}