diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..9cef8dc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,23 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +# To Reproduce +Steps to reproduce the behavior: + +### Which Python version are you using? + +### Which version of youtube-transcript-api are you using? + +### What code / cli command are you executing? + +# Expected behavior +Describe what you expected to happen. + +# Actual behaviour +Describe what is happening instead of the **Expected behavior**. Add error messages if there are any. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..5ce37e3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of how you want youtube-transcript-api to solve your problem. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context about the feature request here. If you have any additional technical information which could be relevant for the implementation, feel free to share them here. diff --git a/youtube_transcript_api/_api.py b/youtube_transcript_api/_api.py index a618b0e..dfb790d 100644 --- a/youtube_transcript_api/_api.py +++ b/youtube_transcript_api/_api.py @@ -92,6 +92,8 @@ class YouTubeTranscriptApi(object): video ids, which could not be retrieved :rtype ({str: [{'text': str, 'start': float, 'end': float}]}, [str]}): """ + assert isinstance(video_ids, list), "`video_ids` must be a list of strings" + data = {} unretrievable_videos = [] @@ -126,6 +128,7 @@ class YouTubeTranscriptApi(object): :return: a list of dictionaries containing the 'text', 'start' and 'duration' keys :rtype [{'text': str, 'start': float, 'end': float}]: """ + assert isinstance(video_id, str), "`video_id` must be a string" return cls.list_transcripts(video_id, proxies, cookies).find_transcript(languages).fetch() @classmethod diff --git a/youtube_transcript_api/test/test_api.py b/youtube_transcript_api/test/test_api.py index ef23f9b..3bda630 100644 --- a/youtube_transcript_api/test/test_api.py +++ b/youtube_transcript_api/test/test_api.py @@ -254,6 +254,14 @@ class TestYouTubeTranscriptApi(TestCase): {'text': 'just something shorter, I made up for testing', 'start': 5.7, 'duration': 3.239} ] ) + + def test_get_transcript__assertionerror_if_input_not_string(self): + with self.assertRaises(AssertionError): + YouTubeTranscriptApi.get_transcript(['video_id_1', 'video_id_2']) + + def test_get_transcripts__assertionerror_if_input_not_list(self): + with self.assertRaises(AssertionError): + YouTubeTranscriptApi.get_transcripts('video_id_1') @patch('youtube_transcript_api.YouTubeTranscriptApi.get_transcript') def test_get_transcripts(self, mock_get_transcript):