Ejemplo n.º 1
0
 def save_poster(self, destination, choose):
     if choose:
         print 'Creating image selection palette(s)...'
         posters = _get_all_posters(self.series_data.posterUrl)
         poster_qty = len(posters)
         if poster_qty <= 1:
             print 'No palette created,', poster_qty, 'image(s) available'
             _save_poster(self.series_data.posterUrl, destination,
                          self.seriesname, 900)
             return
         draw_mosaic(posters)
         choice = get_input('Choose an image to use for series poster: ',
                            '(^$)|(^(Q|q)$)|(^\d{1,2}$)',
                            1, poster_qty)
         if re.match('^(Q|q)$', choice):
             exit()
         if not choice:
             posterUrl = self.series_data.posterUrl
         else:
             posterUrl = re.sub('(http://.*)-(\d{1,2})\.(.{3,4})',
                                '\\1-' + choice + '.\\3',
                                self.series_data.posterUrl)
         _save_poster(posterUrl, destination, self.seriesname, 900)
     else:
         _save_poster(self.series_data.posterUrl, destination,
                      self.seriesname, 900)
Ejemplo n.º 2
0
def download_poster(self, size, destination, choose):
    '''
    download associated movie poster

    size: w92, w154, w185, w342, w500, or original
          see http://help.themoviedb.org/kb/api/configuration
    name: name to save it as
    '''

    if choose:
        print 'Creating image selection palette(s)...'
        posters = _get_all_posters(self.posters, size)
        poster_qty = len(posters)
        if poster_qty <= 1:
            print 'No palette created,', poster_qty, 'image(s) available'
            return download_file(self.poster.geturl(size), destination)
        draw_mosaic(posters)
        choice = get_input('Choose an image to use for movie poster: ',
                           '(^$)|(^(Q|q)$)|(^\d{1,2}$)',
                           1, poster_qty)
        if re.match('^(Q|q)$', choice):
            exit()
        if not choice:
            poster_url = self.poster.geturl(size)
        else:
            poster_url = self.posters[int(choice)-1].geturl(size)
    else:
        poster_url = self.poster.geturl(size)
    image = download_file(poster_url, destination)
    if destination == 'temp':
        return image
    is_reduced = reduce_size(destination, 90)
    if is_reduced:
        notify('warning', 'image quality reduced and useless data removed for '
                + os.path.splitext(os.path.basename(destination))[0], sys.stderr)