Ejemplo n.º 1
0
    def find_more(self, arg=None, menuw=None):
        """
        Find more of this program
        """

        _debug_(String('searching for: %s' % self.prog.title))

        pop = AlertBox(text=_('Searching, please wait...'))
        pop.show()

        items = []
        (result, matches) = record_client.findMatches(self.prog.title)

        pop.destroy()
        if result:
            _debug_('search found %s matches' % len(matches))

            f = lambda a, b: cmp(a.start, b.start)
            matches.sort(f)
            for prog in matches:
                items.append(ProgramItem(self, prog, context='search'))
        else:
            if matches == 'no matches':
                msgtext = _('No matches found for %s') % self.prog.title
                AlertBox(text=msgtext).show()
                return
            AlertBox(text=_('findMatches failed: %s') % matches).show()
            return

        search_menu = menu.Menu(_('Search Results'),
                                items,
                                item_types='tv program menu')

        menuw.pushmenu(search_menu)
        menuw.refresh()
Ejemplo n.º 2
0
    def SetVideoGroup(self, channel):

        _debug_("TunerControl: Play channel = '%s'" % channel)
        vg = self.fc.getVideoGroup(channel, True)
        _debug_("TunerControl: Play group = '%s'" % vg.desc)

        if (vg.group_type != "ivtv"):

            _debug_("TunerControl: Video group '%s' is not supported" %
                    vg.group_type)
            pop = AlertBox(text=_(
                "This plugin only supports the ivtv video group in tv mode!"))
            pop.show()
            return

        if self.ivtv_init == False:

            ivtv_dev = ivtv.IVTV(vg.vdev)
            ivtv_dev.init_settings()
            ivtv_dev.setinput(vg.input_num)
            ivtv_dev.print_settings()

            # disable embedded vbi data
            self.embed = ivtv_dev.getvbiembed()
            ivtv_dev.setvbiembed(0)

            self.ivtv_init = True

        self.fc.chanSet(channel, True)
        self.curr_channel = channel
Ejemplo n.º 3
0
    def SetVideoGroup(self, channel):
        """ select a channel's video group and tune to that channel """
        try:
            channel_num = int(channel)
        except ValueError:
            channel_num = 0
        logger.debug('TunerControl: Channel: %r', channel)
        new_vg = self.fc.getVideoGroup(channel, True)
        logger.debug('TunerControl: Group: type=%r, desc=%r',
                     new_vg.group_type, new_vg.desc)
        logger.debug('TunerControl: Input: type=%r, num=%r', new_vg.input_type,
                     new_vg.input_num)

        if new_vg.group_type != 'ivtv':
            logger.error('TunerControl: VideoGroup %s is not supported',
                         new_vg)
            pop = AlertBox(
                text=_('This plugin only supports the ivtv video group!'))
            pop.show()
            return

        # check if videogroup switch is needed
        switch_vg = not self.ivtv_init or self.curr_channel is None or \
                    new_vg != self.fc.getVideoGroup(self.curr_channel, True)

        if switch_vg:
            # switch to a different video group
            logger.info('TunerControl: Set VideoGroup: %s', new_vg)
            ivtv_dev = ivtv.IVTV(new_vg.vdev)
            ivtv_dev.init_settings()
            self.xine.SetInput(new_vg.input_num)
            # disable embedded vbi data
            self.embed = ivtv_dev.getvbiembed()
            ivtv_dev.setvbiembed(0)

        if not self.ivtv_init:
            # set channel directly on v4l device, if channel is not negative
            if channel_num >= 0:
                self.fc.chanSet(channel, True)
            self.curr_channel = channel
            self.ivtv_init = True
        else:
            # set channel through xine process
            freq = self.fc.chanSet(channel, True, 'ivtv_xine_tv', None)

            if freq != 0:
                # channel has frequency
                logger.debug('TunerControl: Set frequency: %s', freq)
                self.xine.SetFrequency(freq)
            else:
                # channel has no frequency
                logger.debug('TunerControl: Channel has no frequency')

            self.curr_channel = channel
            self.xine.SeekEnd()
            self.ShowInfo()

        self.SetAudioByChannel(channel)
Ejemplo n.º 4
0
 def getNations(self):
     try:
         req = urllib2.Request(url_nations, txdata, txheaders)
         response = urllib2.urlopen(req)
     except:
         print "errore url\n"
         popup.destroy()
         box = AlertBox(text=_('Failed to download channel list'))
         box.show()
         return
     all = ''
     for line in response.read().split('\n'):
         all += line + ' '
     myDict = []
     all = all.replace('\r', '').replace('\t', '').replace('\n', '')
     m = re.compile(
         r'''<a class="rb" href="([^"]*)" target="r">([^<]*)\s+(\d+)\s+</a>''',
         re.IGNORECASE).findall(all)
     if m:
         for url, title, channels in m:
             myDict = [title.strip(), url_base + url, channels]
             self.nation_list.append(myDict)
         self.mainArray['nation_list'] = self.nation_list
         for i in self.nation_list:
             print "Scarico gli stream di: " + i[0]
             try:
                 req = urllib2.Request(i[1], txdata, txheaders)
                 response = urllib2.urlopen(req)
             except:
                 print "errore url\n"
             all = ''
             for line in response.read().split('\n'):
                 all += line
             myChannel = []
             all = all.replace('\r', '').replace('\t', '').replace('\n', '')
             # uncomment for qtl playlist (quicktime)
             #m = re.compile(r'''target="TV">([^<]*)</a></td><td class="(?:qm|qt|qr|wa)"><a class="(r|m|qu|w)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)<font class="hd2">([^>]*)</td></tr>''', re.IGNORECASE).findall(all)
             # without qtl playlists
             m = re.compile(
                 r'''target="TV">([^<]*)</a></td><td class="(?:qm|qr|wa)"><a class="(r|m|w)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)<font class="hd2">([^>]*)</td></tr>''',
                 re.IGNORECASE).findall(all)
             if m:
                 nation_channels = []
                 for tv, gen, url, stream, desc in m:
                     #print tv + " " + gen + " " + url + " " + stream + " " + desc
                     myChannel = eval(url)
                     myDict = [
                         util.htmlenties2txt(tv), myChannel[1], stream,
                         util.htmlenties2txt(desc)
                     ]
                     #          myDict = [myChannel[1], stream]
                     nation_channels.append(myDict)
                 self.nation_tv[i[0]] = nation_channels
             else:
                 print "non trovo corrispondenze!"
             self.mainArray['nation_tv'] = self.nation_tv
Ejemplo n.º 5
0
 def show_status(self, arg=None, menuw=None):
     t = self.rip_thread
     if t.current_track != -1:
         pop = AlertBox(
             text=_('Ripping in progress\nTrack %(current)d of %(total)d') %
             ({
                 'current': t.current_track,
                 'total': t.max_track
             }))
         pop.show()
Ejemplo n.º 6
0
 def getNations(self):
     try:
         req = urllib2.Request(url_nations, txdata, txheaders)
         response = urllib2.urlopen(req)
     except:
         print "errore url\n"
         popup.destroy()
         box = AlertBox(text=_("Failed to download channel list"))
         box.show()
         return
     all = ""
     for line in response.read().split("\n"):
         all += line + " "
     myDict = []
     all = all.replace("\r", "").replace("\t", "").replace("\n", "")
     m = re.compile(r"""<a class="rb" href="([^"]*)" target="r">([^<]*)\s+(\d+)\s+</a>""", re.IGNORECASE).findall(
         all
     )
     if m:
         for url, title, channels in m:
             myDict = [title.strip(), url_base + url, channels]
             self.nation_list.append(myDict)
         self.mainArray["nation_list"] = self.nation_list
         for i in self.nation_list:
             print "Scarico gli stream di: " + i[0]
             try:
                 req = urllib2.Request(i[1], txdata, txheaders)
                 response = urllib2.urlopen(req)
             except:
                 print "errore url\n"
             all = ""
             for line in response.read().split("\n"):
                 all += line
             myChannel = []
             all = all.replace("\r", "").replace("\t", "").replace("\n", "")
             # uncomment for qtl playlist (quicktime)
             # m = re.compile(r'''target="TV">([^<]*)</a></td><td class="(?:qm|qt|qr|wa)"><a class="(r|m|qu|w)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)<font class="hd2">([^>]*)</td></tr>''', re.IGNORECASE).findall(all)
             # without qtl playlists
             m = re.compile(
                 r"""target="TV">([^<]*)</a></td><td class="(?:qm|qr|wa)"><a class="(r|m|w)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)<font class="hd2">([^>]*)</td></tr>""",
                 re.IGNORECASE,
             ).findall(all)
             if m:
                 nation_channels = []
                 for tv, gen, url, stream, desc in m:
                     # print tv + " " + gen + " " + url + " " + stream + " " + desc
                     myChannel = eval(url)
                     myDict = [util.htmlenties2txt(tv), myChannel[1], stream, util.htmlenties2txt(desc)]
                     #          myDict = [myChannel[1], stream]
                     nation_channels.append(myDict)
                 self.nation_tv[i[0]] = nation_channels
             else:
                 print "non trovo corrispondenze!"
             self.mainArray["nation_tv"] = self.nation_tv
Ejemplo n.º 7
0
    def SetVideoGroup(self, channel):
        """ select a channel's video group and tune to that channel """
        try:
            channel_num = int(channel)
        except ValueError:
            channel_num = 0
        logger.debug('TunerControl: Channel: %r', channel)
        new_vg = self.fc.getVideoGroup(channel, True)
        logger.debug('TunerControl: Group: type=%r, desc=%r', new_vg.group_type, new_vg.desc)
        logger.debug('TunerControl: Input: type=%r, num=%r', new_vg.input_type, new_vg.input_num)

        if new_vg.group_type != 'ivtv':
            logger.error('TunerControl: VideoGroup %s is not supported', new_vg)
            pop = AlertBox(text=_('This plugin only supports the ivtv video group!'))
            pop.show()
            return

        # check if videogroup switch is needed
        switch_vg = not self.ivtv_init or self.curr_channel is None or \
                    new_vg != self.fc.getVideoGroup(self.curr_channel, True)

        if switch_vg:
            # switch to a different video group
            logger.info('TunerControl: Set VideoGroup: %s', new_vg)
            ivtv_dev = ivtv.IVTV(new_vg.vdev)
            ivtv_dev.init_settings()
            self.xine.SetInput(new_vg.input_num)
            # disable embedded vbi data
            self.embed = ivtv_dev.getvbiembed()
            ivtv_dev.setvbiembed(0)

        if not self.ivtv_init:
            # set channel directly on v4l device, if channel is not negative
            if channel_num >= 0:
                self.fc.chanSet(channel, True)
            self.curr_channel = channel
            self.ivtv_init = True
        else:
            # set channel through xine process
            freq = self.fc.chanSet(channel, True, 'ivtv_xine_tv', None)

            if freq != 0:
                # channel has frequency
                logger.debug('TunerControl: Set frequency: %s', freq)
                self.xine.SetFrequency(freq)
            else:
                # channel has no frequency
                logger.debug('TunerControl: Channel has no frequency')

            self.curr_channel = channel
            self.xine.SeekEnd()
            self.ShowInfo()

        self.SetAudioByChannel(channel)
Ejemplo n.º 8
0
 def getCategories(self):
     for i in categories:
         try:
             print "download " + i[1] + " url: " + url_ + i[0]
             req = urllib2.Request(url_ + i[0], txdata, txheaders)
             response = urllib2.urlopen(req)
         except:
             print "errore url\n"
             #popup.destroy()
             box = AlertBox(text=_('Failed to download categories list'))
             box.show()
             return
         all = ''
         myDict = []
         for line in response.read().split('\n'):
             all += line
         myChannel = []
         all = all.replace('\r', '').replace('\t', '').replace('\n', '')
         # uncomment for qtl playlist (quicktime)
         #m = re.compile(r'''<tr><td class="q"><font class="hd2">([^<]*)</font></td><td class="name" width="120"><font class="new">(?:(?:[^<]*)|(?:\d\d\d\d-\d\d-\d\d<BR>))</font><a class="travel" href="(?:[^"]*)" target="TV">([^<]*)</a></td><td class="(?:qm|qt|qr|wa)"><a class="(r|m|qu|w)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)></td><td class="qe"><font class="hd2">([^>]*)</td></tr>''', re.IGNORECASE).findall(all)
         # without qtl playlists
         m = re.compile(
             r'''<tr><td class="q"><font class="hd2">([^<]*)</font></td><td class="name" width="120"><font class="new">(?:(?:[^<]*)|(?:\d\d\d\d-\d\d-\d\d<BR>))</font><a class="travel" href="(?:[^"]*)" target="TV">([^<]*)</a></td><td class="(?:qm|qr|wa)"><a class="(r|m|w)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)></td><td class="qe"><font class="hd2">([^>]*)</td></tr>''',
             re.IGNORECASE).findall(all)
         #m = re.compile(r'''<font class="hd2">([^<]*)</font>(?:.*?)target="TV">([^<]*)</a></td><td class="qm"><a class="(r|m|qu)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)<font class="hd2">([^>]*)</td></tr>''', re.IGNORECASE).findall(all)
         if m:
             categories_channels = []
             for state, tv, gen, url, stream, desc in m:
                 #print state + " " + tv + " " + gen + " " + url + " " + stream + " " + desc
                 myChannel = eval(url)
                 mydesc = util.htmlenties2txt(
                     desc) + "\n" + util.htmlenties2txt(state)
                 myDict = [
                     util.htmlenties2txt(tv), myChannel[1], stream, mydesc
                 ]
                 categories_channels.append(myDict)
             self.categories_tv[i[1]] = categories_channels
         else:
             print "non trovo corrispondenze!"
     self.mainArray['categories_tv'] = self.categories_tv
Ejemplo n.º 9
0
 def getCategories(self):
     for i in categories:
         try:
             print "download " + i[1] + " url: " + url_ + i[0]
             req = urllib2.Request(url_ + i[0], txdata, txheaders)
             response = urllib2.urlopen(req)
         except:
             print "errore url\n"
             # popup.destroy()
             box = AlertBox(text=_("Failed to download categories list"))
             box.show()
             return
         all = ""
         myDict = []
         for line in response.read().split("\n"):
             all += line
         myChannel = []
         all = all.replace("\r", "").replace("\t", "").replace("\n", "")
         # uncomment for qtl playlist (quicktime)
         # m = re.compile(r'''<tr><td class="q"><font class="hd2">([^<]*)</font></td><td class="name" width="120"><font class="new">(?:(?:[^<]*)|(?:\d\d\d\d-\d\d-\d\d<BR>))</font><a class="travel" href="(?:[^"]*)" target="TV">([^<]*)</a></td><td class="(?:qm|qt|qr|wa)"><a class="(r|m|qu|w)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)></td><td class="qe"><font class="hd2">([^>]*)</td></tr>''', re.IGNORECASE).findall(all)
         # without qtl playlists
         m = re.compile(
             r"""<tr><td class="q"><font class="hd2">([^<]*)</font></td><td class="name" width="120"><font class="new">(?:(?:[^<]*)|(?:\d\d\d\d-\d\d-\d\d<BR>))</font><a class="travel" href="(?:[^"]*)" target="TV">([^<]*)</a></td><td class="(?:qm|qr|wa)"><a class="(r|m|w)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)></td><td class="qe"><font class="hd2">([^>]*)</td></tr>""",
             re.IGNORECASE,
         ).findall(all)
         # m = re.compile(r'''<font class="hd2">([^<]*)</font>(?:.*?)target="TV">([^<]*)</a></td><td class="qm"><a class="(r|m|qu)" href="javascript:listen([^>]*)">([^<]*)</a> </td><td class="q"><center>(?:.*?)<font class="hd2">([^>]*)</td></tr>''', re.IGNORECASE).findall(all)
         if m:
             categories_channels = []
             for state, tv, gen, url, stream, desc in m:
                 # print state + " " + tv + " " + gen + " " + url + " " + stream + " " + desc
                 myChannel = eval(url)
                 mydesc = util.htmlenties2txt(desc) + "\n" + util.htmlenties2txt(state)
                 myDict = [util.htmlenties2txt(tv), myChannel[1], stream, mydesc]
                 categories_channels.append(myDict)
             self.categories_tv[i[1]] = categories_channels
         else:
             print "non trovo corrispondenze!"
     self.mainArray["categories_tv"] = self.categories_tv
Ejemplo n.º 10
0
    def SetVideoGroup(self, channel):
        """ select a channel's video group and tune to that channel """
        _debug_('TunerControl: Channel: %r' % channel)
        new_vg = self.fc.getVideoGroup(channel, True)
        _debug_('TunerControl: Group: type=%r, desc=%r' %
                (new_vg.group_type, new_vg.desc))
        _debug_('TunerControl: Input: type=%r, num=%r' %
                (new_vg.input_type, new_vg.input_num))

        if (new_vg.group_type != 'ivtv'):
            _debug_(
                'TunerControl: Video group %r is not supported' %
                new_vg.group_type, DERROR)
            pop = AlertBox(
                text=_('This plugin only supports the ivtv video group!'))
            pop.show()
            return

        # check if videogroup switch is needed
        switch_vg = (self.ivtv_init == False) or \
                    (self.curr_channel == None) or \
                    (new_vg != self.fc.getVideoGroup(self.curr_channel, True))

        if switch_vg == True:
            # switch to a different video group
            _debug_('TunerControl: Set video group: %s' % new_vg.vdev, DINFO)
            ivtv_dev = ivtv.IVTV(new_vg.vdev)
            ivtv_dev.init_settings()
            self.xine.SetInput(new_vg.input_num)

            # disable embedded vbi data
            self.embed = ivtv_dev.getvbiembed()
            ivtv_dev.setvbiembed(0)

        if self.ivtv_init == False:
            # set channel directly on v4l device
            self.ivtv_init = True
            self.fc.chanSet(channel, True)
            self.curr_channel = channel

            if config.XINE_TV_LIVE_RECORD:
                # video stream is marked implicitly
                # start timer to mark next show
                self.program_timer()
            else:
                self.ShowInfo()
        else:
            # set channel through xine process

            # get channel frequency
            freq = self.fc.chanSet(channel, True, 'ivtv_xine_tv', None)

            if freq != 0:
                # channel has frequency
                _debug_('TunerControl: Set frequency: %s' % freq)
                self.xine.SetFrequency(freq)
            else:
                # channel has no frequency
                _debug_('TunerControl: Channel has no frequency')

            self.curr_channel = channel

            if config.XINE_TV_LIVE_RECORD:
                # explicitly mark video stream
                self.xine.SetMark()
                # start timer to mark next show
                self.program_timer()
            else:
                self.xine.SeekEnd()
                self.ShowInfo()
Ejemplo n.º 11
0
 def show_status(self, arg=None, menuw=None):
     t = self.rip_thread
     if t.current_track != -1:
         pop = AlertBox(text=_( 'Ripping in progress\nTrack %d of %d' ) % \
                        (t.current_track, t.max_track))
         pop.show()
Ejemplo n.º 12
0
 def show_status(self, arg=None, menuw=None):
     t = self.rip_thread
     if t.current_track != -1:
         pop = AlertBox(text=_('Ripping in progress\nTrack %(current)d of %(total)d') % ({
             'current': t.current_track, 'total': t.max_track}))
         pop.show()
Ejemplo n.º 13
0
    def cwd(self, arg=None, menuw=None):
        """
        Download the url and create a menu with more links
        """
        txdata = None
        txheaders = {
            'User-Agent': 'freevo %s (%s)' % (config.VERSION, sys.platform),
            'Accept-Language': 'en-us',
        }

        popup = PopupBox(text=_('Downloading link list...'))
        popup.show()
        try:
            req = urllib2.Request(self.url, txdata, txheaders)
            response = urllib2.urlopen(req)
        except:
            popup.destroy()
            box = AlertBox(text=_('Failed to download %s') % self.url)
            box.show()
            return

        # base for this url
        self.base = response.geturl()[:response.geturl().rfind('/') + 1]

        # normalize the text so that it can be searched
        all = ''
        for line in response.read().split('\n'):
            all += line + ' '
        all = all.replace('\r', '').replace('\t', ' ')

        # find names for links (text between <a>)
        name_map = {}
        m = re.compile('href="([^"]*)">([^<]*)</a>', re.I).findall(all)
        if m:
            for url, title in m:
                while title.find('  ') > 0:
                    title = title.replace('  ', ' ')
                title = util.htmlenties2txt(title.lstrip().rstrip())
                name_map[url] = title

        # now search for links, normal links and movie links together
        all_urls = []
        movie_regexp = re.compile('.*(mov|avi|mpg|asf)$', re.I)
        for m in (re.compile('href="(.*?)"', re.I).findall(all),
                  re.compile('"(http.[^"]*.(mov|avi|mpg|asf))"',
                             re.I).findall(all)):
            if m:
                for url in m:
                    if isinstance(url, tuple):
                        url = url[0]
                    all_urls.append(url)

        # now split all_urls into link_urls (more links) and
        # movie_urls (video)
        link_urls = []
        movie_urls = []

        if all_urls:
            for url in all_urls:
                long_url = self.make_complete_url(response.geturl(), url)

                # bad url?
                if not long_url:
                    continue

                # find a title
                title = url
                if name_map.has_key(url):
                    title = name_map[url]
                else:
                    title = title.replace('.html', '').replace('.php', '')

                # remove blacklisted urls
                for b in self.blacklist_regexp:
                    if b(long_url):
                        break
                else:
                    # movie or link?
                    if movie_regexp.match(long_url):
                        movie_urls.append((long_url, url, title))
                    else:
                        link_urls.append((long_url, url, title))

        items = []

        # add all link urls
        if link_urls:
            for long, short, title in link_urls:
                # should all links be displayed?
                if (not self.all_links) and long.find(self.base) != 0:
                    continue
                # don't display self
                if long == self.url:
                    continue
                # search for duplicate links
                for l in items:
                    if l.url == long:
                        # increase counter, this link seems to be
                        # important
                        l.counter += 1
                        break

                else:
                    # add link as new new
                    l = Link(title, long, self.blacklist_regexp, self.autoplay,
                             self.all_links, self)
                    l.url_name = short
                    l.image = None
                    items.append(l)

        # sort all items
        items.sort(lambda l, o: cmp(l.sort().upper(), o.sort().upper()))

        # add part of the url to the name in case a title is used for
        # more than one item
        for l in items:
            for o in items:
                if l.name == o.name and l.name.find('(') == -1 and not l == o:
                    # duplicate found, get last part of the url
                    url = l.url[l.url.rfind('/') + 1:]
                    if not url:
                        url = l.url[l.url[:-1].rfind('/') + 1:]
                    if url:
                        l.name = '%s (%s)' % (l.name, url)
                    # same for the other
                    url = o.url[o.url.rfind('/') + 1:]
                    if not url:
                        url = o.url[o.url[:-1].rfind('/') + 1:]
                    if url:
                        o.name = '%s (%s)' % (o.name, url)

        # now search for movies
        movies = []
        if movie_urls:
            for long, short, title in movie_urls:
                # search for duplicate links
                for l in movies:
                    if l.filename == long:
                        break
                else:
                    movies.append(VideoItem(long, self, parse=False))
                    if title.find('/') != -1:
                        title = 'Video: ' + long[long.rfind('/') + 1:]
                    movies[-1].name = title

        # all done
        popup.destroy()
        if len(movies) == 1 and arg == 'autoplay':
            movies[0].play(menuw=menuw)
        elif len(movies) == 1 and arg == 'autoplay_max':
            movies[0].play_max_cache(menuw=menuw)
        elif items or movies:
            menuw.pushmenu(menu.Menu(self.name, movies + items))
Ejemplo n.º 14
0
    def cwd(self, arg=None, menuw=None):
        """
        Download the url and create a menu with more links
        """
        txdata = None
        txheaders = {
            'User-Agent': 'freevo %s (%s)' % (config.VERSION, sys.platform),
            'Accept-Language': 'en-us',
            }

        popup = PopupBox(text=_('Downloading link list...'))
        popup.show()
        try:
            req = urllib2.Request(self.url, txdata, txheaders)
            response = urllib2.urlopen(req)
        except:
            popup.destroy()
            box = AlertBox(text=_('Failed to download %s') % self.url)
            box.show()
            return

        # base for this url
        self.base = response.geturl()[:response.geturl().rfind('/')+1]

        # normalize the text so that it can be searched
        all = ''
        for line in response.read().split('\n'):
            all += line + ' '
        all = all.replace('\r', '').replace('\t', ' ')

        # find names for links (text between <a>)
        name_map = {}
        m = re.compile('href="([^"]*)">([^<]*)</a>', re.I).findall(all)
        if m:
            for url, title in m:
                while title.find('  ') > 0:
                    title = title.replace('  ', ' ')
                title = util.htmlenties2txt(title.lstrip().rstrip())
                name_map[url] = title


        # now search for links, normal links and movie links together
        all_urls = []
        movie_regexp = re.compile('.*(mov|avi|mpg|asf)$', re.I)
        for m in (re.compile('href="(.*?)"', re.I).findall(all),
                  re.compile('"(http.[^"]*.(mov|avi|mpg|asf))"', re.I).findall(all)):
            if m:
                for url in m:
                    if isinstance(url, tuple):
                        url = url[0]
                    all_urls.append(url)


        # now split all_urls into link_urls (more links) and
        # movie_urls (video)
        link_urls  = []
        movie_urls = []

        if all_urls:
            for url in all_urls:
                long_url  = self.make_complete_url(response.geturl(), url)

                # bad url?
                if not long_url:
                    continue

                # find a title
                title = url
                if name_map.has_key(url):
                    title = name_map[url]
                else:
                    title = title.replace('.html', '').replace('.php', '')

                # remove blacklisted urls
                for b in self.blacklist_regexp:
                    if b(long_url):
                        break
                else:
                    # movie or link?
                    if movie_regexp.match(long_url):
                        movie_urls.append((long_url, url, title))
                    else:
                        link_urls.append((long_url, url, title))



        items  = []

        # add all link urls
        if link_urls:
            for long, short, title in link_urls:
                # should all links be displayed?
                if (not self.all_links) and long.find(self.base) != 0:
                    continue
                # don't display self
                if long == self.url:
                    continue
                # search for duplicate links
                for l in items:
                    if l.url == long:
                        # increase counter, this link seems to be
                        # important
                        l.counter += 1
                        break

                else:
                    # add link as new new
                    l = Link(title, long, self.blacklist_regexp, self.autoplay,
                             self.all_links, self)
                    l.url_name = short
                    l.image = None
                    items.append(l)


        # sort all items
        items.sort(lambda l, o: cmp(l.sort().upper(),
                                    o.sort().upper()))

        # add part of the url to the name in case a title is used for
        # more than one item
        for l in items:
            for o in items:
                if l.name == o.name and l.name.find('(') == -1 and not l == o:
                    # duplicate found, get last part of the url
                    url = l.url[l.url.rfind('/')+1:]
                    if not url:
                        url = l.url[l.url[:-1].rfind('/')+1:]
                    if url:
                        l.name = '%s (%s)' % (l.name, url)
                    # same for the other
                    url = o.url[o.url.rfind('/')+1:]
                    if not url:
                        url = o.url[o.url[:-1].rfind('/')+1:]
                    if url:
                        o.name = '%s (%s)' % (o.name, url)

        # now search for movies
        movies = []
        if movie_urls:
            for long, short, title in movie_urls:
                # search for duplicate links
                for l in movies:
                    if l.filename == long:
                        break
                else:
                    movies.append(VideoItem(long, self, parse=False))
                    if title.find('/') != -1:
                        title = 'Video: ' + long[long.rfind('/')+1:]
                    movies[-1].name = title

        # all done
        popup.destroy()
        if len(movies) == 1 and arg=='autoplay':
            movies[0].play(menuw=menuw)
        elif len(movies) == 1 and arg=='autoplay_max':
            movies[0].play_max_cache(menuw=menuw)
        elif items or movies:
            menuw.pushmenu(menu.Menu(self.name, movies + items))