frinkiac.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. """
  2. Frinkiac (Images)
  3. @website https://www.frinkiac.com
  4. @provide-api no
  5. @using-api no
  6. @results JSON
  7. @stable no
  8. @parse url, title, img_src
  9. """
  10. from json import loads
  11. from urllib import urlencode
  12. categories = ['images']
  13. BASE = 'https://frinkiac.com/'
  14. SEARCH_URL = '{base}api/search?{query}'
  15. RESULT_URL = '{base}?{query}'
  16. THUMB_URL = '{base}img/{episode}/{timestamp}/medium.jpg'
  17. IMAGE_URL = '{base}img/{episode}/{timestamp}.jpg'
  18. def request(query, params):
  19. params['url'] = SEARCH_URL.format(base=BASE, query=urlencode({'q': query}))
  20. return params
  21. def response(resp):
  22. results = []
  23. response_data = loads(resp.text)
  24. for result in response_data:
  25. episode = result['Episode']
  26. timestamp = result['Timestamp']
  27. results.append({'template': 'images.html',
  28. 'url': RESULT_URL.format(base=BASE,
  29. query=urlencode({'p': 'caption', 'e': episode, 't': timestamp})),
  30. 'title': episode,
  31. 'content': '',
  32. 'thumbnail_src': THUMB_URL.format(base=BASE, episode=episode, timestamp=timestamp),
  33. 'img_src': IMAGE_URL.format(base=BASE, episode=episode, timestamp=timestamp)})
  34. return results