コード例 #1
0
ファイル: filter.py プロジェクト: BackupTheBerlios/cbt-svn
 def handle_starttag(self, tag, attrs) :
     if tag == 'a' :
         for attr in attrs :
             if attr[0] == 'href' :
                 joined = urlparse.urljoin(self.baseurl, attr[1])
                 #print joined
                 if not joined.startswith('http') :
                     break
                 if joined.endswith('.torrent') :
                     # ok, this should be torrent
                     self.href = 1
                     self.cur_link = (joined, None)
                 else :
                     try :
                         link = urlopen(joined,referer=self.baseurl)
                     except Exception:
                         break
                     if is_torrent(link):
                         self.href = 1
                         m = None
                         if link.info().has_key('Content-Disposition') :
                             m = content_dispo_re.search(link.info()['Content-Disposition'])
                         if m :
                             self.cur_link = (joined, m.group('filename'))
                         else :
                             self.cur_link = (joined, None)
                 break
コード例 #2
0
ファイル: loader.py プロジェクト: BackupTheBerlios/cbt-svn
    def fetch(self):
        self.prefetch()

        media_list = self.filter.process(self.tracker)
        if self.policy(policy.VERIFY_LINK):
            for media in media_list:
                if not (is_movie(media.link) or is_torrent(media.link)) :
                    self.log.warn('link failed: link is not movie or torrent: %s\n' % str(media.link))
        return media_list