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

[Instagram] Extract video dimensions #10790

Closed
wants to merge 1 commit into from

Conversation

TRox1972
Copy link
Contributor

@TRox1972 TRox1972 commented Sep 28, 2016

Please follow the guide below

  • You will be asked some questions, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your pull request (like that [x])
  • Use Preview tab to see how your pull request will actually look like

Before submitting a pull request make sure you have:

In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:

  • 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?

  • Bug fix
  • Improvement
  • New extractor
  • New feature

Description of your pull request and other information

Extracts dimensions from Instagram videos.

formats = [{
'url': self._og_search_video_url(webpage, secure=False),
'height': int_or_none(media.get('dimensions', {}).get('height')),
'width': int_or_none(media.get('dimensions', {}).get('width')),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Code duplication.

formats = [{
'url': media.get('video_url'),
'height': int_or_none(media.get('dimensions', {}).get('height')),
'width': int_or_none(media.get('dimensions', {}).get('width')),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Code duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@TRox1972 TRox1972 force-pushed the instagram_dimension branch 2 times, most recently from ab85482 to 2c18e1a Compare September 28, 2016 17:29
'url': self._og_search_video_url(webpage, secure=False),
'height': height,
'width': width,
}]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nothing really changed. You construct the same structure two times.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

does it look better now?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just

video_url = ...
width = ...
height = ...

...

if not video_url:
    video_url = ...

...

formats = [{
    'url': video_url,
    'width': width,
    'height': height,
}]

Copy link
Contributor Author

@TRox1972 TRox1972 Sep 29, 2016

Choose a reason for hiding this comment

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

That does seem better. Thanks, applied

@TRox1972 TRox1972 force-pushed the instagram_dimension branch 2 times, most recently from df13bf3 to 4f57e36 Compare September 29, 2016 18:10
formats = [{
'url': video_url,
'width': width,
'height': height,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dimensions are uninitialized when media is not available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@dstftw
Copy link
Collaborator

dstftw commented Sep 30, 2016

Cherry-picked in 1609782, thanks.

@dstftw dstftw closed this Sep 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants