-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate the first party YouTube client into Via #1103
Conversation
# By default, the mock reports that URLs are not YouTube URLs. | ||
youtube_service.get_video_id.return_value = None | ||
|
||
return youtube_service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This violated the principal of least surprise for me. This is only required in one test, so I moved it there.
"api.youtube.transcript", | ||
video_id=youtube_service.get_video_id.return_value, | ||
transcript_id="en.a", | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are very intense. I really don't think we should be doing this anyway here which might reduce this effect
|
||
if not youtube_service.enabled: | ||
raise HTTPUnauthorized() | ||
|
||
video_id = youtube_service.get_video_id(url) | ||
video_url = youtube_service.canonical_video_url(video_id) | ||
video_title = youtube_service.get_video_title(video_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think part of the reason these tests aren't as nice as they could be is we have too many atomic calls.
The new method returns a single object with all these items inside it. It would be good to unify these.
if not video_id: | ||
raise BadURL(f"Unsupported video URL: {url}", url=url) | ||
|
||
_, client_config = Configuration.extract_from_params(kwargs) | ||
video_url = youtube_service.canonical_video_url(video_id) | ||
video_title = youtube_service.get_video_title(video_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved these down, because we can early return if the video id isn't valid. Rather than doing lots of strange stuff.
return transcript_id | ||
|
||
# Then look up a transcript matching our preferences | ||
video = youtube_service.get_video_info(video_url=url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could look this up in the parent, but I chose to keep it separate for now.
We could look to unify the look up with a call like:
youtube_service.get_video_info(video_url=url, get_captions=True)
Where we could use V3 stuff if get_captions=False
or the V1 stuff if it's true etc.
51ae7a8
to
6f8b07a
Compare
87ed39a
to
6458ef0
Compare
ce105cd
to
fabdc50
Compare
6458ef0
to
af7c34e
Compare
fabdc50
to
a0a9d19
Compare
af7c34e
to
70077f4
Compare
a0a9d19
to
c935e0a
Compare
70077f4
to
bb3c1e3
Compare
c935e0a
to
2171d2f
Compare
bb3c1e3
to
8bd4b7b
Compare
Labeling this as blocked just because it's waiting for me to get some more urgent PRs done before I can review this. I promise I'm working my way round to reviewing this ASAP! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a proper review yet but just as a first-pass: I think the video_url
argument to get_video_info()
can be removed as it's unused, and the via.video.lang
query param should be removed as nothing's going to be using it
def get_video_info(self, video_id=None, video_url=None) -> Video: | ||
if video_url: | ||
video_id = self.get_video_id(video_url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def get_video_info(self, video_id=None, video_url=None) -> Video: | |
if video_url: | |
video_id = self.get_video_id(video_url) | |
def get_video_info(self, video_id) -> Video: |
The video_url
argument isn't needed: this is only called by get_transcript()
below and it always passes video_id
never video_url
# Try the `via.video.lang` param first | ||
if transcript_id := via_config.get("video", {}).get("lang"): | ||
return transcript_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Try the `via.video.lang` param first | |
if transcript_id := via_config.get("video", {}).get("lang"): | |
return transcript_id |
We should remove this as it'll be dead code: nothing is ever going to be passing the via.video.lang
param. We can add support for this query param back in a later PR when we need it
0a7ed32
to
5ec410d
Compare
This is mostly arranged acount captions, but has room to grow
This _always_ attempts to get the automatically generated English version. We need to fancy this up to try and find any English track.
8bd4b7b
to
e994778
Compare
Closing this, I think it was superseded by #1160 |
Requires:
make requirements
with no changes to requirements #1104Review notes
Testing notes
make dev
en
, though not sure how you'd tell without a break point)