1
0
mirror of https://github.com/instaloader/instaloader.git synced 2024-11-04 09:22:29 +01:00

Merge branch 'master' into upcoming/v4.9

This commit is contained in:
Alexander Graf 2021-11-12 20:28:19 +01:00
commit d6fd4c560c
5 changed files with 31 additions and 18 deletions

View File

@ -6,13 +6,15 @@ labels: "feature suggestion"
--- ---
**Provide us a use case of the feature** **Provide us a use case of the feature**
How could the user invoke the new function? Which problem would it solve? If new information is obtained, how would it be further processed? How could the user invoke the new function? Which problem would it solve?
If new information is obtained, how would it be further processed?
**Describe the solution you'd like** **Describe the solution you'd like**
A clear and concise description of what you want to happen. A clear and concise description of what you want to happen.
**Describe alternatives you've considered** **Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered. A clear and concise description of any alternative solutions or features you've considered.
How do you achieve the here-described goal without the feature you are requesting?
**If the feature request is accepted, would you be willing to submit a pull request?** **If the feature request is accepted, would you be willing to submit a pull request?**
Yes / No Yes / No
@ -21,4 +23,9 @@ Yes / No
**Additional context** **Additional context**
Add any other context about the feature request here. Add any other context about the feature request here.
<!-- please also see https://instaloader.github.io/contributing.html for how to suggest a feature --> <!--
Also see https://instaloader.github.io/contributing.html for how to suggest a feature.
Please understand that a feature suggestion issue that lacks the required information cannot be
processed.
-->

View File

@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
python-version: [3.8, 3.9] python-version: ["3.8", "3.9", "3.10"]
steps: steps:
- name: Checkout Instaloader Repository - name: Checkout Instaloader Repository
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -10,9 +10,9 @@ jobs:
- name: Checkout Instaloader repository - name: Checkout Instaloader repository
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup Python - name: Setup Python
uses: actions/setup-python@v1 uses: actions/setup-python@v2
with: with:
python-version: 3.9 python-version: "3.9"
architecture: x64 architecture: x64
- name: Get the tagged version - name: Get the tagged version
id: get_version id: get_version

View File

@ -45,7 +45,7 @@ with open('__main__.py', 'w+') as f:
# install dependencies and invoke PyInstaller # install dependencies and invoke PyInstaller
commands = ["pip install pipenv==2021.5.29", commands = ["pip install pipenv==2021.5.29",
"pipenv sync --dev", f"pipenv --python {sys.version_info.major}.{sys.version_info.minor} sync --dev",
"pipenv run pyinstaller --log-level=DEBUG instaloader.spec"] "pipenv run pyinstaller --log-level=DEBUG instaloader.spec"]
for command in commands: for command in commands:

View File

@ -377,20 +377,23 @@ class Post:
def video_url(self) -> Optional[str]: def video_url(self) -> Optional[str]:
"""URL of the video, or None.""" """URL of the video, or None."""
if self.is_video: if self.is_video:
version_urls = [self._field('video_url')] version_urls = []
try:
version_urls.append(self._field('video_url'))
except (InstaloaderException, KeyError, IndexError) as err:
self._context.error(f"Warning: Unable to fetch video from graphql of {self}: {err}")
if self._context.iphone_support and self._context.is_logged_in: if self._context.iphone_support and self._context.is_logged_in:
try: try:
version_urls.extend(version['url'] for version in self._iphone_struct['video_versions']) version_urls.extend(version['url'] for version in self._iphone_struct['video_versions'])
except (InstaloaderException, KeyError, IndexError) as err: except (InstaloaderException, KeyError, IndexError) as err:
self._context.error(f"Unable to fetch high-quality video version of {self}: {err}") self._context.error(f"Unable to fetch high-quality video version of {self}: {err}")
return version_urls[0] version_urls = list(dict.fromkeys(version_urls))
else: if len(version_urls) == 0:
return None
if len(version_urls) == 1:
return version_urls[0] return version_urls[0]
url_candidates: List[Tuple[int, str]] = [] url_candidates: List[Tuple[int, str]] = []
for idx, version_url in enumerate(version_urls): for idx, version_url in enumerate(version_urls):
if any(url_candidate[1] == version_url for url_candidate in url_candidates):
# Skip duplicates
continue
try: try:
url_candidates.append(( url_candidates.append((
int(self._context.head(version_url, allow_redirects=True).headers.get('Content-Length', 0)), int(self._context.head(version_url, allow_redirects=True).headers.get('Content-Length', 0)),
@ -1129,20 +1132,23 @@ class StoryItem:
def video_url(self) -> Optional[str]: def video_url(self) -> Optional[str]:
"""URL of the video, or None.""" """URL of the video, or None."""
if self.is_video: if self.is_video:
version_urls = [self._node['video_resources'][-1]['src']] version_urls = []
try:
version_urls.append(self._node['video_resources'][-1]['src'])
except (InstaloaderException, KeyError, IndexError) as err:
self._context.error(f"Warning: Unable to fetch video from graphql of {self}: {err}")
if self._context.iphone_support and self._context.is_logged_in: if self._context.iphone_support and self._context.is_logged_in:
try: try:
version_urls.extend(version['url'] for version in self._iphone_struct['video_versions']) version_urls.extend(version['url'] for version in self._iphone_struct['video_versions'])
except (InstaloaderException, KeyError, IndexError) as err: except (InstaloaderException, KeyError, IndexError) as err:
self._context.error(f"Unable to fetch high-quality video version of {self}: {err}") self._context.error(f"Unable to fetch high-quality video version of {self}: {err}")
return version_urls[0] version_urls = list(dict.fromkeys(version_urls))
else: if len(version_urls) == 0:
return None
if len(version_urls) == 1:
return version_urls[0] return version_urls[0]
url_candidates: List[Tuple[int, str]] = [] url_candidates: List[Tuple[int, str]] = []
for idx, version_url in enumerate(version_urls): for idx, version_url in enumerate(version_urls):
if any(url_candidate[1] == version_url for url_candidate in url_candidates):
# Skip duplicates
continue
try: try:
url_candidates.append(( url_candidates.append((
int(self._context.head(version_url, allow_redirects=True).headers.get('Content-Length', 0)), int(self._context.head(version_url, allow_redirects=True).headers.get('Content-Length', 0)),