Skip to content

Commit

Permalink
Merge pull request #5 from michabirklbauer/develop
Browse files Browse the repository at this point in the history
v1.1.3
  • Loading branch information
michabirklbauer authored Aug 1, 2024
2 parents 5a0e842 + 15ea892 commit 4d17c4c
Show file tree
Hide file tree
Showing 8 changed files with 143 additions and 7 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Docker Image CI

on:
workflow_dispatch:

jobs:

build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Build the Docker image
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username michabirklbauer --password-stdin
docker build . --file Dockerfile --tag michabirklbauer/vscodownloader:latest
docker push michabirklbauer/vscodownloader:latest
GIT_SHA="$(git rev-parse --short HEAD)"
docker tag michabirklbauer/vscodownloader:latest michabirklbauer/vscodownloader:$GIT_SHA
docker push michabirklbauer/vscodownloader:$GIT_SHA
6 changes: 3 additions & 3 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Copy scripts to "/tests"
Expand Down
4 changes: 4 additions & 0 deletions .streamlit/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[theme]
base="light"
[server]
maxUploadSize=2048
Binary file added .streamlit/ico/download-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dockerfile with VSCO Downloader GUI
# author: Micha Birklbauer
# version: 1.0.0

FROM python:3.12.0

LABEL maintainer="[email protected]"

RUN mkdir app
RUN mkdir app/.streamlit
RUN mkdir app/.streamlit/ico
COPY requirements.txt app
COPY vsco_downloader.py app
COPY streamlit_app.py app
COPY .streamlit/config.toml app/.streamlit
COPY .streamlit/ico/download-icon.png app/.streamlit/ico
WORKDIR app
RUN pip install -r requirements.txt

CMD ["streamlit", "run", "streamlit_app.py"]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
streamlit
84 changes: 84 additions & 0 deletions streamlit_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python3

# VSCO Downloader GUI
# 2024 (c) Micha Johannes Birklbauer
# https://github.com/michabirklbauer/
# [email protected]

"""
#####################################################
## ##
## -- STREAMLIT MAIN APP -- ##
## ##
#####################################################
"""

import streamlit as st
from vsco_downloader import download as d

# main page content
def main_page():

title = st.title("VSCO Downloader")

general_description = \
"""
VSCO Downloader is a simple script to extract raw image and video paths from [VSCO](https://www.vsco.co/) posts.
"""
description = st.markdown(general_description)

header_1 = st.subheader("Extract Post Media", divider = "rainbow")

url = st.text_input("VSCO Post URL:",
placeholder = "https://vsco.co/emilieristevski/media/561f648001146426743090fa",
help = "URL of the VSCO post from which media should be extracted.")

l1, l2, center_button, r1, r2 = st.columns(5)

with center_button:
download = st.button("Download!", type = "primary", use_container_width = True)

if download:
media_urls = d(url, True, False)
header_2 = st.subheader("Extracted Post Media", divider = "rainbow")
display_media_urls = st.markdown("\n".join([f"- Found media url: [{media_url}]({media_url})" for media_url in media_urls]))

# side bar and main page loader
def main():

about_str = \
"""
VSCO Downloader is a simple script to extract raw image and video paths from [VSCO](https://www.vsco.co/) posts.
"""

st.set_page_config(page_title = "VSCO Downloader",
page_icon = ":camera:",
layout = "wide",
initial_sidebar_state = "expanded",
menu_items = {"Get Help": "https://github.com/michabirklbauer/vsco_downloader/discussions",
"Report a bug": "https://github.com/michabirklbauer/vsco_downloader/issues",
"About": about_str}
)

title = st.sidebar.title("VSCO Downloader")

div_1 = st.sidebar.subheader("", divider = "rainbow")

logo = st.sidebar.image(".streamlit/ico/download-icon.png",
caption = "VSCO Downloader is a simple script to extract raw image and video paths from VSCO posts.")

#doc = st.sidebar.markdown(about_str)

div_2 = st.sidebar.subheader("", divider = "rainbow")

info_str = ""
info_str += "- **Contact:** \n [[email protected]](mailto:[email protected])\n"
info_str += "- **License:** \n [MIT License](https://github.com/michabirklbauer/vsco_downloader/blob/master/LICENSE.md)\n"
info_str += "- **Project Page:** \n [GitHub](https://github.com/michabirklbauer/vsco_downloader/)"
info = st.sidebar.markdown(info_str)

main_page()

if __name__ == "__main__":

main()
14 changes: 10 additions & 4 deletions vsco_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# https://github.com/michabirklbauer/
# [email protected]

version = "1.0.2"
version = "1.0.3"
date = "20221230"

import urllib.request as ur
Expand All @@ -15,7 +15,7 @@
import os
import re

def download(vsco_media_url, get_video_thumbnails = True):
def download(vsco_media_url, get_video_thumbnails = True, save = True):

request_header = { "User-Agent" : "Mozilla/5.0 (Windows NT 6.1; Win64; x64)" }
request = ur.Request(vsco_media_url, headers = request_header)
Expand All @@ -34,6 +34,10 @@ def download(vsco_media_url, get_video_thumbnails = True):
tb.print_exc()
return 1

opener = ur.build_opener()
opener.addheaders = [("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64)")]
ur.install_opener(opener)

media_urls = []
try:
medias = json_data["medias"]["byId"]
Expand All @@ -42,12 +46,14 @@ def download(vsco_media_url, get_video_thumbnails = True):
if not bool(info["isVideo"]) or get_video_thumbnails:
media_url = "https://" + str(info["responsiveUrl"].encode().decode("unicode-escape"))
media_name = str(media) + ".jpg"
ur.urlretrieve(media_url, media_name)
if save:
ur.urlretrieve(media_url, media_name)
media_urls.append(media_url)
if bool(info["isVideo"]):
media_url = "https://" + str(info["videoUrl"].encode().decode("unicode-escape"))
media_name = str(media) + ".mp4"
ur.urlretrieve(media_url, media_name)
if save:
ur.urlretrieve(media_url, media_name)
media_urls.append(media_url)
except Exception as e:
print("ERROR: Failed to extract image/video location!")
Expand Down

0 comments on commit 4d17c4c

Please sign in to comment.