pax_global_header 0000666 0000000 0000000 00000000064 14575653726 0014536 g ustar 00root root 0000000 0000000 52 comment=5f3d558793b537a74480241ac6981479f5938cd3
woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-imgur/ 0000775 0000000 0000000 00000000000 14575653726 0023165 5 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-imgur/modules/ 0000775 0000000 0000000 00000000000 14575653726 0024635 5 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-imgur/modules/imgur/ 0000775 0000000 0000000 00000000000 14575653726 0025760 5 ustar 00root root 0000000 0000000 woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-imgur/modules/imgur/__init__.py 0000664 0000000 0000000 00000001475 14575653726 0030100 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2016 Vincent A
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see .
from .module import ImgurModule
__all__ = ['ImgurModule']
woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-imgur/modules/imgur/browser.py 0000664 0000000 0000000 00000006113 14575653726 0030016 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2016 Vincent A
#
# This file is part of a woob module.
#
# This woob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This woob module 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this woob module. If not, see .
import dateutil.parser
from woob.browser import URL
from woob.browser.browsers import APIBrowser
from woob.capabilities.gallery import CapGallery
class ImgurBrowser(APIBrowser):
BASEURL = 'https://api.imgur.com'
CLIENT_ID = '87a8e692cb09382'
SORT_TYPE = {
CapGallery.SEARCH_DATE: 'time',
CapGallery.SEARCH_VIEWS: 'viral',
CapGallery.SEARCH_RATING: 'top',
CapGallery.SEARCH_RELEVANCE: 'top',
}
search_url = URL(r'/3/gallery/search/(?P\w+)/(?P\d+)/\?q=(?P.*)')
get_gallery_url = URL(r'/3/album/(?P\w+)')
get_image_url = URL(r'/3/image/(?P\w+)')
def open_raw(self, *args, **kwargs):
return super(ImgurBrowser, self).open(*args, **kwargs)
def fill_file(self, file, fields):
response = self.open_raw(file.url)
if 'date' in fields:
file.date = dateutil.parser.parse(response.headers.get('Date'))
if 'data' in fields:
file.data = response.content
if 'size' in fields:
file.size = len(response.content)
def open(self, *args, **kwargs):
kwargs.setdefault('headers', {})
kwargs['headers']['Authorization'] = 'Client-ID %s' % self.CLIENT_ID
return super(ImgurBrowser, self).open(*args, **kwargs)
def request(self, *args, **kwargs):
reply = super(ImgurBrowser, self).request(*args, **kwargs)
if reply['success']:
return reply['data']
def post_image(self, b64, title=''):
res = {}
params = {'image': b64, 'title': title or '', 'type': 'base64'}
info = self.request('https://api.imgur.com/3/image', data=params)
if info is not None:
res['id'] = info['id']
res['delete_url'] = 'https://api.imgur.com/3/image/%s' % info['deletehash']
return res
def get_image(self, id):
url = self.get_image_url.build(browser=self, id=id)
return self.request(url)
def get_gallery(self, id):
url = self.get_gallery_url.build(browser=self, id=id)
return self.request(url)
def search_items(self, pattern, sortby):
sortby = self.SORT_TYPE[sortby]
url = self.search_url.build(browser=self, sort_type=sortby, page=1, pattern=pattern)
info = self.request(url)
if info is None:
return []
return info
woob-master-5f3d558793b537a74480241ac6981479f5938cd3-modules-imgur/modules/imgur/favicon.png 0000664 0000000 0000000 00000000705 14575653726 0030115 0 ustar 00root root 0000000 0000000 PNG
IHDR @ @ iq bKGD pHYs tIME ;ϝH tEXtComment Created with GIMPW -IDATx1DMJ*i It(o`h)EQV,q}>G #Bm M `9`]apR `v #
@] T``=ʨ`9Guذn%+ qT&