get_cover.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from aiomysql import DictCursor
  2. # fetch
  3. async def fetch_channel_info(pools, content_id):
  4. """use content id to get channel_content_id && channel code"""
  5. fetch_query = f"""
  6. select t1.channel_content_id, t2.channel
  7. from produce_plan_exe_record t1 join crawler_content t2 on t1.channel_content_id = t2.channel_content_id
  8. where plan_exe_id = '{content_id}';
  9. """
  10. fetch_response = await pools.async_fetch(
  11. query=fetch_query, db_name="aigc_db_pool", cursor_type=DictCursor
  12. )
  13. return fetch_response
  14. async def fetch_aigc_cover(pools, channel_content_id):
  15. """
  16. use channel_content_id to find article cover
  17. """
  18. fetch_query = f"""
  19. select image_url, oss_object_key
  20. from crawler_content_image
  21. where channel_content_id = '{channel_content_id}' and image_type = 2;
  22. """
  23. fetch_response = await pools.async_fetch(
  24. query=fetch_query, db_name="aigc_db_pool", cursor_type=DictCursor
  25. )
  26. return fetch_response
  27. async def fetch_long_video_cover(pools, channel_content_id):
  28. """
  29. use channel_content_id to find long video cover
  30. """
  31. fetch_query = f"""
  32. select image_path
  33. from video_cover_snapshots
  34. where video_id = '{channel_content_id}';
  35. """
  36. fetch_response = await pools.async_fetch(
  37. query=fetch_query, db_name="long_video_db_pool", cursor_type=DictCursor
  38. )
  39. return fetch_response