# -*- coding: utf-8 -*- # # gPodder - A media aggregator and podcast client # Copyright (c) 2005-2018 The gPodder Team # # gPodder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # gPodder is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # # gpodder.coverart - Unified cover art downloading module (2012-03-04) # import logging import os import shutil import urllib.parse import gpodder from gpodder import util, youtube _ = gpodder.gettext logger = logging.getLogger(__name__) class CoverDownloader(object): # File name extension dict, lists supported cover art extensions # Values: functions that check if some data is of that file type SUPPORTED_EXTENSIONS = { '.png': lambda d: d.startswith(b'\x89PNG\r\n\x1a\n\x00'), '.jpg': lambda d: d.startswith(b'\xff\xd8'), '.gif': lambda d: d.startswith(b'GIF89a') or d.startswith(b'GIF87a'), '.ico': lambda d: d.startswith(b'\0\0\1\0'), '.svg': lambda d: d.startswith(b'