Skip to content

Commit

Permalink
Merge pull request #3 from michabirklbauer/develop
Browse files Browse the repository at this point in the history
fix unicode escaped character decoding
  • Loading branch information
michabirklbauer authored Dec 30, 2022
2 parents f16d4c3 + 76de469 commit 54dd613
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
Expand Down
11 changes: 7 additions & 4 deletions vsco_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# https://github.com/michabirklbauer/
# [email protected]

version = "1.0.1"
date = "20221230"

import urllib.request as ur
import traceback as tb
import json
Expand All @@ -15,7 +18,7 @@
def download(vsco_media_url, get_video_thumbnails = True):

request_header = { "User-Agent" : "Mozilla/5.0 (Windows NT 6.1; Win64; x64)" }
request = ur.Request(vsco_media_url, headers=request_header)
request = ur.Request(vsco_media_url, headers = request_header)
data = ur.urlopen(request).read()

data_cleaned_1 = str(data).split("<script>window.__PRELOADED_STATE__ =")[1]
Expand All @@ -37,12 +40,12 @@ def download(vsco_media_url, get_video_thumbnails = True):
for media in medias:
info = medias[media]["media"]
if not bool(info["isVideo"]) or get_video_thumbnails:
media_url = "https://" + str(info["responsiveUrl"])
media_url = "https://" + str(info["responsiveUrl"].encode().decode("unicode-escape"))
media_name = media_url.split("/")[-1]
ur.urlretrieve(media_url, media_name)
media_urls.append(media_url)
if bool(info["isVideo"]):
media_url = "https://" + str(info["videoUrl"])
media_url = "https://" + str(info["videoUrl"].encode().decode("unicode-escape"))
media_name = media_url.split("/")[-1]
ur.urlretrieve(media_url, media_name)
media_urls.append(media_url)
Expand All @@ -60,7 +63,7 @@ def vsco_downloader(option = None, arg = None):
prompt_str = "Please enter an URL to an VSCO post e. g. " + link + " \n"
url = input(prompt_str)
r = download(url)
if r != 0:
if r != 1:
print("Download successfully!")
return 0
else:
Expand Down

0 comments on commit 54dd613

Please sign in to comment.