Esempio n. 1
0
 def summary(self):
     """parses the episode's summary from the episode's tvrage page"""
     try:
         if timeout:
             page = _fetch(self.link, timeout=timeout).read()
         else:
             page = _fetch(self.link).read()
         if not 'Click here to add a summary' in page:
             summary = parse_synopsis(page, cleanup='var addthis_config')
             return summary
     except Exception, e:
         print('Episode.summary: %s, %s' % (self, e))
Esempio n. 2
0
 def synopsis(self):
     """scraps the synopsis from the show's tvrage page using a regular
     expression. This method might break when the page changes. unfortunatly
     the episode summary isnt available via one of the xml feeds"""
     try:
         if timeout:
             page = _fetch(self.link, timeout=timeout).read()
         else:
             page = _fetch(self.link).read()
         synopsis = parse_synopsis(page)
         return synopsis
     except Exception, e:
         logger.error('Show.synopsis:urlopen: %s, %s' % (self, e))
Esempio n. 3
0
def _fetch_xml(url, node=None, timeout=None):
    """fetches the response of a simple xml-based webservice. If node is
    omitted the root of the parsed xml doc is returned as an ElementTree object
    otherwise the requested node is returned"""
    if timeout:
        xmldoc = _fetch(url, timeout=timeout)
    else:
        xmldoc = _fetch(url)
    result = et.parse(xmldoc)
    root = result.getroot()
    if not node:
        retval = root
    else:
        retval = root.find(node)
    return retval
Esempio n. 4
0
 def recap(self):
     """parses the episode's recap text from the episode's tvrage recap
     page"""
     try:
         if timeout:
             page = _fetch(self.recap_url, timeout=timeout).read()
         else:
             page = _fetch(self.recap_url).read()
         if not 'Click here to add a recap for' in page:
             recap = parse_synopsis(page,
                                    cleanup='Share this article with your'
                                            ' friends')
             return recap
     except Exception, e:
         logger.error('Episode.recap:urlopen: %s, %s' % (self, e))
Esempio n. 5
0
def fetch(show, exact=False, ep=None):
    query_string = '?show=' + quote(show)
    if exact:
        query_string = query_string + '&exact=1'
    if ep:
        query_string = query_string + '&ep=' + quote(ep)
    resp = _fetch(BASE_URL + query_string).read()
    show_info = {}
    if 'No Show Results Were Found For' in resp:
        raise ShowNotFound(show)
    else:
        data = resp.replace('<pre>', '').splitlines()
        for line in data:
      ne in data:
            try:
                if '@@' in line:
                    line = line.replace('@@','@')
                    k, v = line.split('@')
                    v = '@' + v
                else:
                    k, v = line.split('@')

            except ValueError, err:

                except ValueError, err: #"Ended@"
                    k = line.replace('@',"")
                    v = ""
Esempio n. 6
0
 def summary(self):
     """parses the episode's summary from the episode's tvrage page"""
     try:
         page = _fetch(self.link).read()
         if not 'Click here to add a summary' in page:
             summary = parse_synopsis(page, cleanup='var addthis_config')
             return summary
     except Exception, e:
         print('Episode.summary: %s, %s' % (self, e))
Esempio n. 7
0
 def synopsis(self):
     """scraps the synopsis from the show's tvrage page using a regular
     expression. This method might break when the page changes. unfortunatly
     the episode summary isnt available via one of the xml feeds"""
     try:
         page = _fetch(self.link).read()
         synopsis = parse_synopsis(page)
         return synopsis
     except Exception, e:
         print('Show.synopsis:urlopen: %s, %s' % (self, e))
Esempio n. 8
0
def _fetch_xml(url, node=None):
    """fetches the response of a simple xml-based webservice. If node is
    omitted the root of the parsed xml doc is returned as an ElementTree object
    otherwise the requested node is returned"""
    xmldoc = _fetch(url)
    result = et.parse(xmldoc)
    root = result.getroot()
    if not node:
        retval = root
    else:
        retval = root.find(node)
    return retval
Esempio n. 9
0
 def recap(self):
     """parses the episode's recap text from the episode's tvrage recap
     page"""
     try:
         page = _fetch(self.recap_url).read()
         if not 'Click here to add a recap for' in page:
             recap = parse_synopsis(page,
                                    cleanup='Share this article with your'
                                    ' friends')
             return recap
     except Exception, e:
         print('Episode.recap:urlopen: %s, %s' % (self, e))
Esempio n. 10
0
def fetch(show, exact=False, ep=None, timeout=None):
    query_string = '?show=' + quote(show)
    if exact:
        query_string += '&exact=1'
    if ep:
        query_string += '&ep=' + quote(ep)

    if timeout is None:
        resp = _fetch(BASE_URL + query_string).read()
    else:
        resp = _fetch(BASE_URL + query_string, timeout=timeout).read()

    show_info = {}
    if 'No Show Results Were Found For' in resp:
        raise ShowNotFound(show)
    else:
        data = resp.replace('<pre>', '').splitlines()
        for line in data:
            splits = line.split('@')
            k, v = splits[0], '@'.join(splits[1:])
            # TODO: use datetimeobj for dates
            show_info[k] = (v.split(' | ') if ' | ' in v else
                            (v.split('^') if '^' in v else v))
    return show_info
Esempio n. 11
0
def fetch(show, exact=False, ep=None):
    query_string = '?show=' + quote(show)
    if exact:
        query_string = query_string + '&exact=1'
    if ep:
        query_string = query_string + '&ep=' + quote(ep)
    resp = _fetch(BASE_URL + query_string).read()
    show_info = {}
    if 'No Show Results Were Found For' in resp:
        raise ShowNotFound(show)
    else:    
        data = resp.replace('<pre>', '').splitlines()
        for line in data:
            k, v = line.split('@')
            # TODO: use datetimeobj for dates
            show_info[k] = (v.split(' | ') if ' | ' in v else 
                                (v.split('^') if '^' in v else v)) 
    return show_info