Use voussoirkit.vlogging for loud.

This commit is contained in:
voussoir 2020-11-09 16:30:54 -08:00
parent a3f69573a4
commit aabb6691f0

View file

@ -1,10 +1,12 @@
import bs4 import bs4
import logging
import requests import requests
from voussoirkit import vlogging
from . import exceptions from . import exceptions
log = logging.getLogger(__name__) log = vlogging.getLogger(__name__)
session = requests.Session() session = requests.Session()
def _get_user_videos(uid): def _get_user_videos(uid):
@ -15,6 +17,7 @@ def _get_user_videos(uid):
soup = bs4.BeautifulSoup(response.text, 'lxml') soup = bs4.BeautifulSoup(response.text, 'lxml')
# find_all does not work on namespaced tags unless you add a limit paramter. # find_all does not work on namespaced tags unless you add a limit paramter.
video_ids = [v.text for v in soup.find_all('yt:videoid', limit=9999)] video_ids = [v.text for v in soup.find_all('yt:videoid', limit=9999)]
log.loud('RSS got %s.', video_ids)
return video_ids return video_ids
def get_user_videos(uid): def get_user_videos(uid):
@ -29,4 +32,6 @@ def get_user_videos_since(uid, most_recent_video):
index = video_ids.index(most_recent_video) index = video_ids.index(most_recent_video)
except ValueError: except ValueError:
raise exceptions.RSSAssistFailed(f'RSS didn\'t contain {most_recent_video}.') raise exceptions.RSSAssistFailed(f'RSS didn\'t contain {most_recent_video}.')
return video_ids[:index] video_ids = video_ids[:index]
log.loud('Since %s: %s', most_recent_video, str(video_ids))
return video_ids