Example #1
0
def save(self, filename, webm, thumb):
    if not filename:
        return

    if webm:
        filename += '.webm'
        path = os.path.join(get_media_folder(self._webm_obj, filename),
                            filename)
        webm_path = default_storage.save(path, ContentFile(webm))
        self._webm_obj.video = webm_path

    if thumb:
        filename += '.jpg'
        path = os.path.join(get_media_folder(self._webm_obj, filename),
                            filename)
        thumb_path = default_storage.save(path, ContentFile(thumb))
        self._webm_obj.thumbnail = thumb_path

    try:
        self._webm_obj.save()
    except IntegrityError as e:
        self._webm_obj = Webm.objects.get(md5=self._webm_obj.md5)
        scraper.inform(e, level=scraper.WARNING)
    finally:
        self._add_releated_info()
Example #2
0
def save(self, filename, webm, thumb):
    if not filename:
        return

    if webm:
        filename += '.webm'
        path = os.path.join(
            get_media_folder(self._webm_obj, filename), filename)
        webm_path = default_storage.save(path, ContentFile(webm))
        self._webm_obj.video = webm_path

    if thumb:
        filename += '.jpg'
        path = os.path.join(
            get_media_folder(self._webm_obj, filename), filename)
        thumb_path = default_storage.save(path, ContentFile(thumb))
        self._webm_obj.thumbnail = thumb_path

    try:
        self._webm_obj.save()
    except IntegrityError as e:
        self._webm_obj = Webm.objects.get(md5=self._webm_obj.md5)
        scraper.inform(e, level=scraper.WARNING)
    finally:
        self._add_releated_info()
Example #3
0
    def _download(self, data):
        self._webm_url, md5 = data[0], data[-1]
        self._webm_obj, created = Webm.get_or_increase_rating(md5)

        if not created:
            result = None, None, None
            scraper.inform('Increase rating {}'.format(self._webm_url),
                           level=scraper.WARNING)
            self._add_releated_info()
        else:
            result = super()._download(data)

        return result
    def _download(self, data):
        self._webm_url, md5 = data[0], data[-1]
        self._webm_obj, created = Webm.get_or_increase_rating(md5)

        if not created:
            result = None, None, None
            scraper.inform(
                'Increase rating {}'.format(self._webm_url), level=scraper.WARNING)
            self._add_releated_info()
        else:
            result = super()._download(data)

        return result
Example #5
0
 def _f(self):
     try:
         return function(self)
     except IntegrityError as e:
         scraper.inform(e, level=scraper.WARNING)
 def _f(self):
     try:
         return function(self)
     except IntegrityError as e:
         scraper.inform(e, level=scraper.WARNING)