# -*- coding: utf-8 -*- # -*- Mode: Python; -*- # vi:si:et:sw=2:sts=2:ts=2 from urllib import quote import re from BeautifulSoup import BeautifulSoup from utils import read_url, stripTags from btutils import torrentsWeLike def search(query): '''search for torrents on btjunkie ''' url = "http://btjunkie.org/search?q=%s&c=6&t=0&o=52&m=0&l=1" % quote(query) page = read_url(url) soup = BeautifulSoup(page) torrents = soup.findAll('a', {'class': 'BlckUnd'}) torrents = filter(torrentsWeLike, torrents) torrent_links = [] for t in torrents: tlink = "http://btjunkie.org%s.torrent" % t.attrMap['href'] tlink = tlink.replace('do=stat', 'do=download') torrent_links.append(tlink) return torrent_links def searchByImdb(imdb): '''search for torrents by imdb, not supported on btjunkie right now ''' return []