17334
![]() |
|
|
|
|
|||||||
| Userland Programming & Scripting C, Shell, Perl, Sed & Awk |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Greetings fellow FreeBSD-users.
I have a problem that I need a solution to, and I think a simple script might do the work; however I am not skilled in scripting and thus I come asking for help. The scenario: I run FreeBSD 9 on a small home server, using to ZFS disks in a single pool. I use transmission-daemon to handle all my downloads (by just saving the torrent to my watch-folder) and all my downloads are going in one folder (/srv/download). I then manually copy all the downloaded material to the corresponding folder, every once per week or so. Music to /srv/music, movies to /srv/movies, tv-series to /srv/tv-series and misc to /srv/misc. I prefer to name my folders manually, for example /srv/movies/movie_title_2012. Tv-series goes to /srv/tv-series/title/season_0X/. The problem: I find this repetitive task somewhat boring, and in the UNIX world I think a script could be able to do the legwork for me. I have tried a couple of small programs previously, while running Linux, but they always messed up the names, or placed the wrong content in the wrong folder. The naming in /srv/music does not matter, since the music client mostly handles the identification fairly well. Does anyone have a suggestion on how to do this? If more information is needed, please let me know. Regards, Johan Last edited by DutchDaemon; April 21st, 2012 at 00:57. Reason: Proper formatting: http://forums.freebsd.org/showthread.php?t=8816 |
|
#2
|
|||
|
|||
|
transmission-remote
-w switch. |
|
#3
|
|||
|
|||
|
Thank you for responding. But this does not solve the issue with naming etc.
I would think that a cronjob that did the following would be best:
Last edited by DutchDaemon; April 21st, 2012 at 00:57. |
|
#4
|
|||
|
|||
|
I might add that I have a "flexget" cronjob to download things I subscribe to. So I am not adding the torrents myself half of the time.
|
|
#5
|
||||
|
||||
|
Perhaps filebot?
In addition to a gui it has a cmdline interface that could be suitable for scripting.
__________________
Practical latin Amicule, deliciae, num is sum qui mentiar tibi? But dear, could I ever lie to you? |
| The Following User Says Thank You to jalla For This Useful Post: | ||
Kveras (April 22nd, 2012) | ||
|
#6
|
||||
|
||||
|
Quote:
|
|
#8
|
||||
|
||||
|
So exactly how will that tell me that x-files.avi is one of the feature length movies or if it one of the tv episodes?
|
|
#9
|
||||
|
||||
|
Something like this, run from a cron job.
WARNING: Quick, dirty and untested. Code:
#!/usr/local/bin/python
import os
import sys
import subprocess
VIDEO_FILE_TYPES = ['avi','mpg','mkv','divx','vob','mp4','m4v']
AUDIO_FILE_TYPES = ['mp3','ogg','flac','wav']
DOWNLOAD_DIR = '/srv/download'
DESTINATION_FILE = '/srv/{TYPE}/{FILENAME}'
MOVE_COMMAND = 'mv {SRC} {DEST}'
def main():
for root, dir, files in os.walk(DOWNLOAD_DIR):
for filename in files:
try:
fn, ext = filename.split('.',1).lower()
if ext in VIDEO_FILE_TYPES:
file_type='movie'
elif ext in VIDEO_FILE_TYPES:
file_type='music'
else:
file_type='misc'
source_file = os.path.join(root, filename)
DESTINATION_FILE.format(TYPE=file_type, FILENAME=filename)
MOVE_COMMAND.format(SRC=source_file, DEST=DESTINATION_FILE)
rtn = subprocess.call(MOVE_COMMAND, shell=True)
except IndexError:
print 'File: %s - has no extension' % (file)
if __name__ == '__main__':
main()
|
| The Following User Says Thank You to roddierod For This Useful Post: | ||
Kveras (April 22nd, 2012) | ||
|
#10
|
|||
|
|||
|
Sorry, I'm referring to the thread subject
|
|
#11
|
|||
|
|||
|
Quote:
However, I get the following: Code:
-> python script.py
Traceback (most recent call last):
File "script.py", line 36, in <module>
main()
File "script.py", line 18, in main
fn, ext = filename.split('.',1).lower()
AttributeError: 'list' object has no attribute 'lower'
|
|
#12
|
||||
|
||||
|
Change this line
Code:
fn, ext = filename.split('.',1).lower()
Code:
fn, ext = filename.lower().split('.',1)
Last edited by DutchDaemon; April 22nd, 2012 at 04:16. |
|
#13
|
|||
|
|||
|
With FileBot scripting feature you can take care of everything you need quite easily. Check out the example scripts.
There's an example on how do something similar with µTorrent. Should be straight-forward to adjust things for transmission: http://filebot.sourceforge.net/forum...p?f=4&t=5#p802 Here's another tutorial on monitoring completed downloads: http://www.torrent-invites.com/audio...t-copying.html Last edited by DutchDaemon; May 13th, 2012 at 23:03. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [Solved] find files older than 10 min - script/cmd problem | da1 | Userland Programming & Scripting | 3 | August 5th, 2011 14:54 |
| [Solved] I want move big files from FreeBSD box to Linux Box with USB flash | mfaridi | General | 4 | January 4th, 2011 15:07 |
| tftp server - downloaded files log & server_args ? | jenaniston | Networking | 2 | January 20th, 2010 15:28 |
| cd to sub-folder on Flash using Script | iic2 | Userland Programming & Scripting | 8 | April 7th, 2009 12:49 |
| [Solved] mutt move msg to folder | graudeejs | Installation and Maintenance of FreeBSD Ports or Packages | 2 | March 5th, 2009 21:46 |