It is currently Sat Nov 26, 2011 7:52 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Downloading TV torrents to seperate folders
PostPosted: Wed Jan 28, 2009 3:04 am 
Offline

Joined: Sat Jan 24, 2009 3:59 am
Posts: 3
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++;
           }



Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 9:35 am 
Offline
Lead Developer
User avatar

Joined: Mon Jan 16, 2006 4:11 pm
Posts: 645
Location: Netherlands
dude thnx for your code snippet! we will build in this functionality in the release after ted 0.97 (where we are working on right now).

does this do everything you want to? or do you still miss some functionality?

_________________
Roel

i watch: simpsons, south park, lost, top gear, true blood & fringe
download - documentation - bugs/feature requests - sourceforge -


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 11:15 am 
Offline
Lead Developer
User avatar

Joined: Mon Jan 16, 2006 5:46 pm
Posts: 904
Location: Netherlands
Cool! This is why we became open source :)

If you want to help us out even more, create UI for this feature, make it more flexible for the user so he can define his own format, etc, please contact me or roel. We can give you access to the source control and stuff like that.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 4:47 pm 
Offline

Joined: Sat Jan 24, 2009 3:59 am
Posts: 3
It doesn't quite do everything I'd want it to do. Give me some time this weekend so I can add it to the GUI, also maybe we can allow people to configure the folder names e.g. they could specify ${season.name}_${season.number}/


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 4:59 pm 
Offline

Joined: Sat Jan 24, 2009 3:59 am
Posts: 3
Also I'm running into issues trying to "build" the TED application into a standalone application instead of just running it from eclipse.

What is the build/release procedure I tried using the Eclipse jar builder descriptors in there but that didn't quite seem to work. Also how do you go about building the Mac OSX .app file (i'm running on a Mac myself), it looks like I may be able to just drop the newly built jar into the built TED.app directory structure.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 5:11 pm 
Offline
Lead Developer
User avatar

Joined: Mon Jan 16, 2006 4:11 pm
Posts: 645
Location: Netherlands
I think we would like it as an option near the download folder settings in the preferences. And I think just offering a checkbox is good enough.

Personally I would like something like "Lost/Season 5" to be the final result.

To build the jar, use the new ted jar.jardesc in the runnable ted folder.

You can drop the new ted.jar in the ted.app indeed. we did add two new jar's for RSS parsing a week ago (jdom.jar/rome.jar), be sure to include them as well.

_________________
Roel

i watch: simpsons, south park, lost, top gear, true blood & fringe
download - documentation - bugs/feature requests - sourceforge -


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 13, 2009 5:19 pm 
Offline
Lead Developer
User avatar

Joined: Mon Jan 16, 2006 4:11 pm
Posts: 645
Location: Netherlands
Oh and make sure you can handle daily shows as well, they don't have a season number. So when a serie.isDaily() == true, make sure to skip the season folder and save the torrent in the show folder.

_________________
Roel

i watch: simpsons, south park, lost, top gear, true blood & fringe
download - documentation - bugs/feature requests - sourceforge -


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2009 11:46 am 
Offline

Joined: Thu Feb 19, 2009 11:29 am
Posts: 4
I have been looking at the source. However, I'm having trouble making sense of it. Do you guys gather around in freenode's IRC so we could have a chat?

I'd love to help you guys out!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2009 2:54 pm 
Offline
Lead Developer
User avatar

Joined: Mon Jan 16, 2006 5:46 pm
Posts: 904
Location: Netherlands
You're troubled by our well designed, beautifully documented code??? :)

I send you a PM with my contact details!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group