mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Validate parameters in _get_updates
This commit is contained in:
@ -16,23 +16,24 @@ def handler(event, context):
|
||||
raise ValueError('Invalid resource URL %s' % url)
|
||||
|
||||
start = event.get('start', 1)
|
||||
count = event.get('count', 50)
|
||||
|
||||
kind = event.get('kind', 'video_high')
|
||||
last_id = event.get('last_id', None)
|
||||
|
||||
print('Getting updated for %s (start=%d, count=%d, kind: %s, last id: %s)' % (url, start, count, kind, last_id))
|
||||
return _get_updates(start, count, url, kind, last_id)
|
||||
|
||||
|
||||
def _get_updates(start, count, url, kind, last_id=None):
|
||||
if start < 1:
|
||||
raise ValueError('Invalid start value')
|
||||
|
||||
count = event.get('count', 50)
|
||||
if count < 1 or count > 600:
|
||||
raise ValueError('Invalid count value')
|
||||
|
||||
end = start + count - 1
|
||||
|
||||
kind = event.get('kind', 'video_high')
|
||||
last_id = event.get('last_id', None)
|
||||
|
||||
print('Getting updated for %s (start=%d, end=%d, kind: %s, last id: %s)' % (url, start, end, kind, last_id))
|
||||
return _get_updates(start, end, url, kind, last_id)
|
||||
|
||||
|
||||
def _get_updates(start, end, url, kind, last_id=None):
|
||||
opts = {
|
||||
'playliststart': start,
|
||||
'playlistend': end,
|
||||
|
@ -7,7 +7,7 @@ class TestUpdater(unittest.TestCase):
|
||||
kinds = ['video_high', 'video_low', 'audio_high', 'audio_low']
|
||||
for kind in kinds:
|
||||
with self.subTest(kind):
|
||||
result = function._get_updates(1, 2, 'https://www.youtube.com/user/CNN/videos', kind)
|
||||
result = function._get_updates(1, 1, 'https://www.youtube.com/user/CNN/videos', kind)
|
||||
self.assertIsNotNone(result['feed'])
|
||||
self.assertIsNotNone(result['items'])
|
||||
|
||||
|
Reference in New Issue
Block a user