Rename variables uid->channel_id, most_recent_video->video_id.
This commit is contained in:
parent
5a868dc7bd
commit
4d80237456
1 changed files with 10 additions and 10 deletions
|
@ -9,9 +9,9 @@ log = vlogging.getLogger(__name__)
|
|||
|
||||
session = requests.Session()
|
||||
|
||||
def _get_user_videos(uid):
|
||||
log.info(f'Fetching RSS for {uid}.')
|
||||
url = f'https://www.youtube.com/feeds/videos.xml?channel_id={uid}'
|
||||
def _get_user_videos(channel_id):
|
||||
log.info(f'Fetching RSS for {channel_id}.')
|
||||
url = f'https://www.youtube.com/feeds/videos.xml?channel_id={channel_id}'
|
||||
response = session.get(url)
|
||||
response.raise_for_status()
|
||||
soup = bs4.BeautifulSoup(response.text, 'lxml')
|
||||
|
@ -20,18 +20,18 @@ def _get_user_videos(uid):
|
|||
log.loud('RSS got %s.', video_ids)
|
||||
return video_ids
|
||||
|
||||
def get_user_videos(uid):
|
||||
def get_user_videos(channel_id):
|
||||
try:
|
||||
return _get_user_videos(uid)
|
||||
return _get_user_videos(channel_id)
|
||||
except Exception:
|
||||
raise exceptions.RSSAssistFailed(f'Failed to fetch RSS videos.') from exc
|
||||
|
||||
def get_user_videos_since(uid, most_recent_video):
|
||||
video_ids = get_user_videos(uid)
|
||||
def get_user_videos_since(channel_id, video_id):
|
||||
video_ids = get_user_videos(channel_id)
|
||||
try:
|
||||
index = video_ids.index(most_recent_video)
|
||||
index = video_ids.index(video_id)
|
||||
except ValueError:
|
||||
raise exceptions.RSSAssistFailed(f'RSS didn\'t contain {most_recent_video}.')
|
||||
raise exceptions.RSSAssistFailed(f'RSS didn\'t contain {video_id}.')
|
||||
video_ids = video_ids[:index]
|
||||
log.loud('Since %s: %s', most_recent_video, str(video_ids))
|
||||
log.loud('Since %s: %s', video_id, str(video_ids))
|
||||
return video_ids
|
||||
|
|
Loading…
Reference in a new issue