Welcome

Hi there my name is Alan MacGregor and this is my blog, hope you enjoy it :)

31 Jan 2009

Viewing Current Transfers in torrentflux-b4rt

I haven't used torrentflux-b4rt in a while on my server mainly due to the fact that it was slightly unstable on my machine however there are still people who use it, for those that do I have a little present.

This python script will display the current transfers of the torrents that are running, all you need to specify is where fluxcli.php is located, as with all my scripts this is free to use in whatever you want, have fun

#!/usr/bin/python

# import modules
import os

os.system("clear")

# Initialise Variables
fluxcli = "/var/www/torrent/bin/fluxcli.php"
temp = "/tmp/current_trans"

print "-------------------------------"
print "------ Current Transfers ------"
print "-------------------------------"

os.system("rm " + temp)
os.system(fluxcli + " transfers >> " + temp)

f = open(temp, 'r')

seeding = []
leeching = []


all_lines = f.readlines()
## Get Number Of Lines
number = 0
for line in all_lines[2:]:
number = number + 1

for line in all_lines[2:number - 3]:

line = line.split("\n")
line = line[0]
line = line.split("- ")
if "0.0 kB/s " == line[8] and line[9]:
templine = ""
elif line[12] == "Download Succeeded! ":
templine = ""
elif line[12] == "Download Succeeded ":
templine = ""
elif line[12] == "Torrent Stopped ":
templine = ""
elif line[12] == "Transfer Died ":
templine = ""
elif line[9] == "- ":
templine = ""
elif line[12] == "Stopped ":
templine = ""
elif line[12] == "repaired ":
templine = ""
else:
leeching.append(line[2] + line[1] + line[8])
if "0.0 kB/s " == line[9] and line[8]:
templine = ""
elif line[12] == "Download Succeeded! ":
templine = ""
elif line[12] == "Download Succeeded ":
templine = ""
elif line[12] == "Torrent Stopped ":
templine = ""
elif line[12] == "Stopped ":
templine = ""
elif line[12] == "Transfer Died ":
templine = ""
elif line[9] == "- ":
templine = ""
elif line[12] == "repaired ":
templine = ""
else:
seeding.append(line[2] + line[1] + line[9])

print "Leeching:"
for i in range(len(leeching)):
print leeching[i]
print "-------"
print "Seeding:"
for i in range(len(seeding)):
print seeding[i]

Who's using the machine

Yesterday I was sitting at work, trying to figure out our current IP situation, it was in a mess and hadn't been updated in a long while. The problem is machines will come and will be issued with IP Addresses and machine names however when they go (or get taken away without us knowing) the log doesnt get updated. The only way we could do this before would be to go and check each machine individually and check the settings, however this is quite unpractical realistically. However we still need this information to find out where machines are located, again this may change in the future :(

Thankfully there is a little application called Nbtstat which allows us to find out who is logged into which machine and with this we can determine where the computer is located. The code can be executed by running in cmd
nbtstat -a computer_name
nbtstat -A ip_address

For the future it would be great if we could run a script that would run this each day through the subnet and export the result as a spreadsheet, with this information we could sort out our IP issues and clear and organise them a lot better

More information is available here
http://www.windowsnetworking.com/kbase/WindowsTips/WindowsNT/AdminTips/Accounts/Nbtstatrevealswhoisloggedon.html

Page Layout

I've just updated the layout from the old boring blogger template, I'm still working on a few of the kinks but I hope you enjoy the changes I've made :)

29 Jan 2009

Deleting items from an iTunes playlist

Hi there, this is a quick tip.

When you itunes you may have realised that deleting a track from a playlist will just remove the link from your file to the playlist but not the library, if you want to remove it from the library as well do the following:
1) Select the item(s)
2) Press CTRL + SHIFT + DELETE
And thats it, it'll ask you for confirmation but it makes things so much easier, such as creating a smart playlist for podcasts with a playcount of >0 and then you can remove all of the podcasts youve listened to already. Altogether it will keep your collection nice and clean

26 Jan 2009

Modifying Apple Propriety Audio Software

So I'm sitting here in the office during my lunch break watch Hak5 (Mad props) and I'm looking for something to do, this is when I realise all of my mp3s on my server and that I need to get them onto iTunes at home. The disadvantage is that im not at home and I'm on a very slow network connection (500k for the whole office!!) so I'll need something light preferably over ssh. Thats when I remembered Atomic Parsley.

Atomic Parsley is a little unix application (windows available through cygwin) that allows you to edit the metadata inside of the m4a files (note I convert mp3 to m4a with pacpl and don't start with 'quality issues' the audio is for me and no one else). The website explains that the tags inside are now refered by Apple as Atoms and take 4 bytes for each Atom. With this you can modify almost all of the data needed in your collection.

This is particularly useful if like me you have a strict policy on the content in your Library to allow better workings on it, with this you can just drag'n'drop your m4as into the library an itunes will do the rest

Atomic Parsley can be downloaded at http://atomicparsley.sourceforge.net/

19 Jan 2009

Torrent linker

Hello there, so its been a while and I really will try to post more, to say sorry I've written some python goodness for you.

This little application was written to organise my torrents, I'm currently using utorrent over wine on my Linux server and most of my torrents are from private trackers each with their own tracker hostname. What this application does is creates a link to your torrents but puts them in a folder depending on what hostname it is, this way when I connect to my XBMC I can see all of the videos from www.thebox.bz and not the audio from what.cd or the videos from passthepopcorn. This also helps management on your system.

To set this up you need to ammend the 4 lines that are at the top of the script refering to folders
- torrentfilesdirectory (folder holding the completed *.torrent)
- torrent_completed_dir (folder holding the complteted files)
- link_directory (folder to create the links in)
- torrent_move_to_dir (folder to move the *.torrents into)

As always the code is open source so do what you want from it, happy new year

import os
import sys
from commands import getoutput

#Declare Variables
torrentfilesdirectory = "/torrent/torrentfilescompleted/"
torrent_completed_dir = "/torrent/completed/"
link_directory = "/torrent/links/"
torrent_move_to_dir = "/torrent/torrentfilescompletedandlinked/"
ary_errors = []
ary_directory = []
ary_tracker = []
ary_torrent = []

#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(": ")
directory = directory[1]

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

#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)):
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];
Template by - Abdul Munir | Daya Earth Blogger Template