updated database.py and bittorrent.py

Updated database.py to stop metadata locking with MySQL 5.5.
Rewrote parts of bittorrent.py to better detect bittorrent files and handle them accordingly.  Probably needs some error handling if it falls through/fails.