def download_torrent(torrent): """This function downloads a torrent :param torrent: Name of the torrent to be downloaded """ fname = os.getcwd() + '/' + hshelper.replace_special_chars(torrent[0]) + '.torrent' with open (fname, 'wb') as f: f.write(urllib2.urlopen(torrent[1]).read()) f.close() subprocess.call(["C:\\Program Files (x86)\\uTorrent\\uTorrent.exe", fname]) hsdb.update_anime(str(torrent[2]), str(int(torrent[3]) + 1))
# hshelper.usage() # hsdb.init_sql() # run the application if len(sys.argv) == 2 and sys.argv[1] == '-r': hsrun.run_one_time() # run the application if len(sys.argv) == 2 and sys.argv[1] == '-rb': window = MainApplication.MainApplication() window.mainloop() # # run the application 'cron' way # if len(sys.argv) == 2 and sys.argv[1] == '-rb': # s = sched.scheduler(time.time, time.sleep) # s.enter(60, 1, hsrun.run, (s,)) # s.run() # add a manga if len(sys.argv) == 4 and sys.argv[1] == '-a': hsdb.add_anime(sys.argv[2], sys.argv[3]) # delete a manga if len(sys.argv) == 3 and sys.argv[1] == '-da': hsdb.delete_anime(sys.argv[2]) # update a manga if len(sys.argv) == 4 and sys.argv[1] == '-ua': hsdb.update_anime(sys.argv[2], sys.argv[3]) # list all mangas if len(sys.argv) == 2 and sys.argv[1] == '-la': hsdb.get_animes_for_print()