Skip to content

Commit

Permalink
typing improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dermasmid committed Sep 5, 2021
1 parent a246c7a commit d708cdd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions scrapetube/scrapetube.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Generator
from typing import Generator, Literal
import requests
import json
import time
Expand All @@ -9,7 +9,7 @@ def get_channel(
channel_url: str = None,
limit: int = None,
sleep: int = 1,
sort_by: str = 'newest'
sort_by: Literal['newest', 'oldest', 'popular'] = 'newest'
) -> Generator[dict, None, None]:

"""Get videos for a channel.
Expand Down Expand Up @@ -68,7 +68,14 @@ def get_playlist(playlist_id: str, limit: int = None, sleep: int = 1) -> Generat
yield video


def get_search(query: str, limit: int = None, sleep: int = 1, sort_by: str = 'relevance', results_type: str = 'video') -> Generator[dict, None, None]:
def get_search(
query: str,
limit: int = None,
sleep: int = 1,
sort_by: Literal['relevance', 'upload_date', 'view_count', 'rating'] = 'relevance',
results_type: Literal['video', 'channel', 'playlist', 'movie'] = 'video'
) -> Generator[dict, None, None]:

"""Search youtube and get videos.
Parameters:
Expand Down

0 comments on commit d708cdd

Please sign in to comment.