Skip to content
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

[ie/floatplane] Add extractor #8639

Merged
merged 10 commits into from Nov 26, 2023
Merged

[ie/floatplane] Add extractor #8639

merged 10 commits into from Nov 26, 2023

Conversation

seproDev
Copy link
Collaborator

@seproDev seproDev commented Nov 22, 2023

IMPORTANT: PRs without the template will be CLOSED

Description of your pull request and other information

Alternative implementation to #5912, supporting audio entries and multiple videos in a single post.
Most posts on the site only contain a single video; thus I decided to only return a single video instead of a playlist in those cases and use the post metadata for that video. This is also how the site visually represents it.
Posts with multiple videos/audio files get returned as a playlist.

Fixes #5877, Closes #5912

Template

Before submitting a pull request make sure you have:

In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

@seproDev seproDev added the site-request Request to support a new website label Nov 22, 2023
@seproDev seproDev added the pending-review PR needs a review label Nov 22, 2023
@Grub4K
Copy link
Member

Grub4K commented Nov 22, 2023

Shouldnt display id and id be swapped? I think we would also have to do the workaround for flat filtering here by forcing return type

@seproDev
Copy link
Collaborator Author

Swapping display_id and id would cause all items in a post with multiple videos to have the same id.

I think we would also have to do the workaround for flat filtering here by forcing return type

I'm not quite sure what you are referring to. Do I need to add '_type': 'video' to all video items?

Initially, I didn't want to bother with this, but it seemed easy enough
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
@bashonly bashonly self-requested a review November 23, 2023 05:51
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
yt_dlp/extractor/floatplane.py Outdated Show resolved Hide resolved
@bashonly bashonly removed the pending-review PR needs a review label Nov 23, 2023
seproDev and others added 3 commits November 23, 2023 19:58
Co-authored-by: bashonly <88596187+bashonly@users.noreply.github.com>
@bashonly bashonly merged commit 628fa24 into yt-dlp:master Nov 26, 2023
15 checks passed
@seproDev seproDev deleted the floatplane branch November 26, 2023 04:19
yt_dlp/extractor/floatplane.py Show resolved Hide resolved
Comment on lines +176 to +177
uploader_url = format_field(traverse_obj(
post_data, 'creator'), 'urlname', 'https://www.floatplane.com/channel/%s/home', default=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, format_field does traverse_obj(obj, *variadic(field)). So you don't need traverse_obj inside it again.

format_field(post_data, [('creator', 'urlname')], 'https://www.floatplane.com/channel/%s/home') or None

Alternately, this also works:

traverse_obj(post_data, ('creator', 'urlname', {lambda x: f'https://www.floatplane.com/channel/{x}/home'}))

Copy link
Collaborator Author

@seproDev seproDev Nov 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I tried that, but didn't realize field needs to be put in a list. Good suggestion.

The alternative could end up with https://www.floatplane.com/channel/None/home

Comment on lines +201 to +205
if len(items) > 1:
return self.playlist_result(items, **post_info)

post_info.update(items[0])
return post_info
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We see this pattern a lot. Should probably be a helper function. Maybe self.playlist_or_video_result(post_info, items)

Comment on lines +267 to +268
display_id, playlist_title=channel_data.get('title') or creator_data.get('title'),
playlist_description=channel_data.get('about') or creator_data.get('about'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
display_id, playlist_title=channel_data.get('title') or creator_data.get('title'),
playlist_description=channel_data.get('about') or creator_data.get('about'))
display_id, title=channel_data.get('title') or creator_data.get('title'),
description=channel_data.get('about') or creator_data.get('about'))

is preferable imo.

Comment on lines +249 to +252
yield self.url_result(
f'https://www.floatplane.com/post/{post["id"]}',
ie=FloatplaneIE, video_id=post['id'], video_title=post.get('title'),
release_timestamp=parse_iso8601(post.get('releaseDate')))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I'd prefer to not use video_title keyword

Suggested change
yield self.url_result(
f'https://www.floatplane.com/post/{post["id"]}',
ie=FloatplaneIE, video_id=post['id'], video_title=post.get('title'),
release_timestamp=parse_iso8601(post.get('releaseDate')))
yield self.url_result(
f'https://www.floatplane.com/post/{post["id"]}',
FloatplaneIE, id=post['id'], title=post.get('title'),
release_timestamp=parse_iso8601(post.get('releaseDate')))

aalsuwaidi pushed a commit to aalsuwaidi/yt-dlp that referenced this pull request Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site-request Request to support a new website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Floatplane
4 participants