Commit Graph

262 Commits

Author SHA1 Message Date
Chris Howell c4b8b5b18d formatters.py python 2 compliant and misc.
Remove use of ABC, not part of Python 2 and implementing ABCMeta changes between Python 2 and 3 so left it out entirely. Base class now raises NotImplementedError manually.

Fix parse_timecode issue with start and end times being identical

Replaced uses of F-strings with .format() also for compatibility.
2020-07-09 20:13:58 -07:00
Chris Howell 74d36a821e Update CLI to make use of new DELIMITER and combine method 2020-07-09 00:06:36 -07:00
Chris Howell 5861bdb104 Remove json.dumps from test_api.py
Remove unnecessary changes to tests, revert assertions back to how they were.

Remove unnecessary join from formatter in `_api.py`
2020-07-09 00:06:14 -07:00
Chris Howell 1c0d584959 Add more functionality to TranscriptFormatter base class
Due to the behavior of the CLI and API, needed more flexibility for combining 1 or many transcripts for a given formatter.

- Now can specify a DELIMITER to separate multiple transcripts on.
- Can also specify how those items are combine overriding the combine class method.

Remove unused imports
Fix adjust some lines to meet PEP
2020-07-09 00:04:08 -07:00
Chris Howell 2c79bd563c Fix _api.py old kwarg 2020-07-08 15:25:32 -07:00
Chris Howell c78a37b115 Update _cli.py
Add formats factory instance that uses the `parsed_args.format` arg to retrieve the formatter class, defaults to JSON if not passed or if given a bad/mistyped name.

Might consider error in the case of a bad name given. Shouldn't be too difficult to add that ability if its wanted.
2020-07-08 15:23:10 -07:00
Chris Howell b4592043dc Add format kwarg to method calls to pass around
Add format kwarg that defaults to None which still gets interpreted to use JSON when its not passed. This kwarg was given to `.get_transcripts()` and `.get_transcript()` since one relies on the other therefore can forward the kwarg.
2020-07-08 15:20:47 -07:00
Chris Howell 0e6fae2504 replace CLI json arg with format in test_cli.py
Replaced every occurance of `parsed_args.json` with `parsed_args.format` as well as the CLI arguments to match for testing.
2020-07-08 15:14:32 -07:00
Chris Howell ac75f906e6 Update test_api.py
Fixed an encoding issue for Windows machines receiving an error due to Lines 24-27:
`UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 119434: character maps to <undefined>`.

Adjusted test_api.py to fix an issue when the format=None isnt passed with mock test raising:
`AssertionError: get_transcript('video_id_1', ['de', 'en'], None, None) call not found`

Added `import json` to convert test data for json data into a string for 1 or many json transcripts to keep in line with how the formatters are eventually returned as strings.
2020-07-08 15:11:54 -07:00
Chris Howell dca4021dd7 Add formatters module
Add formatters module that contains a few basic built-in formatters for JSON, SRT, and an arbitrary plain TEXT. Mainly for examples of implementing your own.

Module contains an abstract base class `TranscriptFormatter` so that anyone can create their own TranscriptFormatter class

Module contains at runtime a `formats` which is basically an instance of a factory of classes (not sure if that is the correct term to use). But it itself is an instance that folks can add custom formatter classes that the API can make use of.
2020-07-08 15:05:17 -07:00
Jonas Depoix dec09fa48a v0.3.1 2020-02-16 14:22:59 +01:00
Jonas Depoix 6751a47171 fixed typo in README 2020-02-16 14:04:53 +01:00
Jonas Depoix 21de9d606a v0.3.0 2020-01-31 11:31:21 +01:00
jdepoix 6da4d19978
Merge pull request #46 from danielcliu/feature/issue-45-use-authentication-cookies
Feature/issue 45 use authentication cookies
2020-01-31 11:29:25 +01:00
Jonas Depoix a0823ea36f added documentation for using cookies feature via CLI to the README 2020-01-31 11:26:39 +01:00
danielcliu 31b8f4a179 Redid errors for cookies, improved testing coverage 2020-01-30 21:53:18 -08:00
danielcliu 49ccba7f95 Fixed testing with mock, added testing for cookies 2020-01-27 21:47:04 -08:00
danielcliu 42d4f59e01 Moved cookie loader to its own function, made errors for cookies failing 2020-01-27 21:46:37 -08:00
danielcliu 67604ec46c Made testing more robust 2020-01-22 22:35:35 -08:00
danielcliu f9e553ebaf Added cli support, fixed testing 2020-01-20 23:04:46 -08:00
danielcliu dc9fc2ee93 Updated Readme to include how to use cookies with the module 2020-01-15 22:48:26 -08:00
danielcliu 02b1978217 Added cookies parameter to api class methods 2020-01-15 22:48:00 -08:00
danielcliu edefeeaf1d
Merge pull request #1 from jdepoix/master
Updating to current master
2020-01-09 18:56:45 -08:00
Jonas Depoix 7dfe20fde4 v0.2.1 2019-12-31 00:13:13 +01:00
jdepoix bfecd64b85
Merge pull request #43 from jdepoix/bugfix/cli-language-default
fixed bug in cli where no transcript could be retrieved if no language was specified
2019-12-31 00:12:39 +01:00
Jonas Depoix 7159f60823 fixed bug in cli where no transcript could be retrieved if no language was specified 2019-12-31 00:11:52 +01:00
Jonas Depoix 0901fe3053 v0.2.0 2019-12-30 23:50:43 +01:00
jdepoix 68951600d9
Merge pull request #42 from jdepoix/feature/translating-transcripts
Feature/translating transcripts
2019-12-30 23:49:20 +01:00
Jonas Depoix 889cedcbf0 fixed typo 2019-12-30 18:41:08 +01:00
Jonas Depoix aa34a2ceb3 updated README 2019-12-30 18:21:45 +01:00
Jonas Depoix 936ef3c1d0 added list-transcripts param to cli 2019-12-30 17:40:32 +01:00
Jonas Depoix f8416ab004 added new params to cli to make new features accessible using the cli 2019-12-30 17:36:48 +01:00
Jonas Depoix 4b75a47a74 get_transcripts now returns a list of exceptions instead of video ids of failed videos 2019-12-30 16:13:18 +01:00
Jonas Depoix 66d02c08a1 added tests for new public api method 2019-12-30 15:34:35 +01:00
Jonas Depoix 1bc5087575 added public list_transcripts method 2019-12-30 15:20:47 +01:00
Jonas Depoix 8287d1088e fixed bug where nontranslatable transcripts would throw an exception 2019-12-30 14:38:27 +01:00
Jonas Depoix f1e4754ca4 added check if any transcripts are actually available 2019-12-20 16:28:35 +01:00
Jonas Depoix 20612ea7a3 improved tostring methods 2019-12-16 17:08:14 +01:00
Jonas Depoix 409141ab51 added translate feature; added iterator to TranscriptList 2019-12-16 16:58:26 +01:00
jdepoix a1b1e001fe
Merge pull request #37 from danielcliu/bugfix/ISSUE-35
Bugfix/issue 35
2019-12-16 16:29:25 +01:00
Jonas Depoix 41300585a1 fixed bug where undesirable results where returned if the desired language was only available as generated transcript 2019-12-13 11:15:32 +01:00
Jonas Depoix c2c49c3c17 fixed bug; added doctstrings for public methods 2019-12-11 11:42:14 +01:00
Jonas Depoix df417be915 refactored the way transcript information is retrieved and thereby improved error messages 2019-12-08 14:40:57 +01:00
danielcliu 54ef72fafd Improve Name regex to use 1 group, find first & 2019-11-11 19:58:12 -08:00
danielcliu d224b02a80 Languages argument defaults to a tuple instead of a list. 2019-11-10 22:44:24 -08:00
danielcliu c7cb3117be Removed unnecessary language variables, sort split matches by len while ignoring name arguement 2019-11-06 21:20:51 -08:00
danielcliu 7ac7d3266b Changed youtubeWWW1.html.static's name 2019-11-06 21:19:24 -08:00
danielcliu db7b8524dc Removed another f-string instance 2019-10-22 21:03:41 -07:00
danielcliu 630b33f3b8 Removed fstrings to make compatable with python 3.5 and lower 2019-10-22 20:37:46 -07:00
danielcliu d8b5208824 Modified README 2019-10-21 22:38:17 -07:00