Archive for the ‘twitter’ category

#BongShower

June 18th, 2012

It’s a thing

Torrent Linker: Update

October 29th, 2010

A while ago I came up with a python script to link torrent newly downloaded torrent files to a folder allowing you to manage data more effectively whilst seeding. However I have only just realised that the initial script does not work as the importer appears to have removed the spaces at the start of each line making the code unusable. As I cannot find my original code here is an update that also features a twitter integration to send you a twitter message when a file has completed.

All you have to do is modify the items inside of “Modify These Variables”, also ensure to set your torrent program to move your completed torrents to the ‘torrentfilesdirectory’ folder

import os
import sys
from commands import getoutput

#Declare Variables
ary_errors    = []
ary_directory = []
ary_tracker   = []
ary_torrent   = []

#Modify These Variables
torrentfilesdirectory = "/torrent/torrentfilescompleted/"
torrent_completed_dir = "/torrent/completed/"
link_directory        = "/torrent/links/"
torrent_move_to_dir   = "/torrent/torrentfilescompletedandlinked/"
twitter_username      = "##########"
twitter_password      = "##########"

#Add list of torrents into variable
torrent_list = getoutput("ls " + torrentfilesdirectory)

#=====================================================
def WorkOnTorrents(line):
 #Read data from torrent
 directory = getoutput("btshowmetainfo \"" + torrentfilesdirectory + line + "\" | grep \"directory name:\"")
 directory = directory + getoutput("btshowmetainfo \"" + torrentfilesdirectory + line + "\" | grep \"file name.....:\"")
 tracker = getoutput("btshowmetainfo \"" + torrentfilesdirectory + line + "\" | grep \"announce url..:\"")

 #Modify the directory variable
 directory = directory.split(": ")[1]

 #Modify the tracker variable
 try:
  tracker = tracker.split("\n")[0].split("/")[2].split(":")[0]
  torrent_valid = "Works"
 except:
  torrent_valid = "Fails"

 print tracker;

 #Add torrent variables to arrays
 if torrent_valid == "Works":
  # Check Against Identified Errors
  if tracker == "":
   ary_errors.append(line);
  else:
   ary_tracker.append(tracker);
   ary_directory.append(directory);
   ary_torrent.append(line);

torrent_list = torrent_list.split("\n")
for line in torrent_list:
 WorkOnTorrents(line)

#=====================================================
## Create Links
print "Executing Links"
for i in range(len(ary_tracker)):
 os.system("curl -u " + twitter_username + ":" + twitter_password + " -d status=\"" + ary_torrent[i] + "\" http://twitter.com/statuses/update.xml")
 print "Creating Link for: " + ary_torrent[i];
 if os.path.exists(link_directory + ary_tracker[i]) == 1:
  os.system("ln -s \"" + torrent_completed_dir + ary_directory[i] + "\" \"" + link_directory + ary_tracker[i] + "/" + ary_directory[i] + "\"")
 else:
  os.system("mkdir " + link_directory + ary_tracker[i])
  os.system("ln -s \"" + torrent_completed_dir + ary_directory[i] + "\" \"" + link_directory + ary_tracker[i] + "/" + ary_directory[i] + "\"")
 os.system("mv \"" + torrentfilesdirectory + ary_torrent[i] + "\" " + torrent_move_to_dir);

#=====================================================
## Display Error Torrents
if len(ary_errors) > 0:
 print "Errors Found:";
 for i in range(len(ary_errors)):
  print ary_errors[i];

My Twitter Page

September 23rd, 2009

As you can see this blog is pretty empty, mainly because I keep forgetting to update it (I will be updating it soon with some more code), however I do have a twitter page now which I update a lot, you can view the page at this address: http://twitter.com/severedspirit