Ejemplo n.º 1
0
def check_db(video_id: str) -> bool:
    """Query the database and assert if the value exists.

    Args:
        video_id (str): The id of a youtube video

    Returns:
        False: if video does not exist
        True: if video does exist

    Raises:
        TypeError: invalid video_id type
    """

    if not isinstance(video_id, str):
        raise TypeError(f'{video_id} should be str not {type(video_id)}')

    result = [i['_id'] for i in COLLECTION.find({'_id': video_id})]

    if not result:
        ret = False
    else:
        ret = True
    return ret
Ejemplo n.º 2
0
#!/usr/bin/env python3
# pylint: disable=all
from app.database import COLLECTION

videos = [(i['title'], i['_id']) for i in COLLECTION.find({}, {
    'title': True,
    '_id': True
})]

for i in videos:
    print(i[1] + '~$' + i[0])