Skip to content

Commit

Permalink
Merge pull request #4 from shaenr/refactor
Browse files Browse the repository at this point in the history
Got an exe working in windows with pyinstaller.exe
  • Loading branch information
shaenr authored Mar 21, 2022
2 parents c6716d3 + 2aaa18c commit 83b123a
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 38 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,6 @@ dmypy.json

.idea/
zips/*
./src/geckodriver.log
./src/geckodriver.log
build/*
dist/*
7 changes: 3 additions & 4 deletions SETUP.sh → LINUX_SETUP.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ echo
echo "INSTRUCTIONS:"
echo
echo "#################################################################################"
echo "CONFIGURE: MAKE YOUR src/bcfg/settings.py file LOOK something like this example"
echo "CONFIGURE: MAKE YOUR ./bcfg/settings.py file LOOK something like this example"
echo "#################################################################################"
echo
echo
cat ./src/bcfg/settings_example.py
cat ./bcfg/settings_example.py
echo
echo
echo "#################################################################################"
read -p 'Press ENTER to edit the file' uservar
echo
export EDITOR="/usr/bin/nano"
$EDITOR ./src/bcfg/settings.py
bash ./START_DOWNLOADING.sh
$EDITOR ./bcfg/settings.py
3 changes: 3 additions & 0 deletions LINUX_START_DOWNLOADING.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

python3 bandcamp_flac_get.py
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ You have to tell the program where the browser binary is, what browser you're us
You can type this to begin setting it up in your terminal...

```bash
bash ./SETUP.sh
bash ./LINUX_SETUP.sh
```

...or you can just open the settings files. They are found here:
Expand All @@ -67,7 +67,7 @@ https://demondice.bandcamp.com/album/shut-up-get-happy
Once those two/three things are done, all you need to do is:

```bash
bash ./START_DOWNLOADING.sh
bash ./LINUX_START_DOWNLOADING.sh
```

If everything is done right, it should just start doing it for you.
Expand Down
3 changes: 0 additions & 3 deletions START_DOWNLOADING.sh

This file was deleted.

10 changes: 4 additions & 6 deletions src/main.py → bandcamp_flac_get.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from bcfg import bcfg
from bcfg import settings
from bcfg import bcfg, settings

import sys
import logging
from argparse import Namespace
from pathlib import Path
from cli import get_argv
from bcfg.cli import get_argv
from shaen_logger import slog
from shaen_logger.log import set_log_level
from constants import REQ_PY_VER
from bcfg.constants import REQ_PY_VER


# def get_log_level(ns: Namespace):
Expand Down Expand Up @@ -37,7 +35,7 @@ def main(argv: Namespace):

slog.info("=" * 20)
slog.info("STARTING NEW EXECUTION...")
slog.info("Running main.py")
slog.info("Running bandcamp_flac_get.py")
slog.info("=" * 20)
slog.debug(f"slog: handlers={slog.handlers}, level={slog.level}")

Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 5 additions & 6 deletions src/cli.py → bcfg/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import sys
from argparse import (
Namespace,
FileType,
ArgumentParser,
RawDescriptionHelpFormatter
Expand All @@ -10,25 +8,26 @@

def get_argv():
parser = ArgumentParser(
prog="bandcamp-flac-get/src/main.py",
prog="bandcamp_flac_get.py",
description="Generate flac/mp3/vorbis download links for bandcamp albums that are free (or name your own"
"price with no minimum price). It will download a zip with cover image, metadata, and files organized into "
"folders.",
formatter_class=RawDescriptionHelpFormatter
)

parser.add_argument('input',
parser.add_argument('--albums-txt',
dest="input",
type=FileType('r'),
default=settings.ALBUM_LINKS_TXT,
help="Read this txt file for bandcamp album links...")
help="Specify a txt file with bandcamp album links to download: one link per line...")

# verbosity_group = parser.add_mutually_exclusive_group(required=False)
# verbosity_group.add_argument("-v", "--verbose", default=2, action="count",
# help="increase logging level.")
# verbosity_group.add_argument("-q", "--quiet", default=1, action="count",
# help="decrease logging level.")

browser_group = parser.add_mutually_exclusive_group(required=True)
browser_group = parser.add_mutually_exclusive_group(required=False)
browser_group.add_argument("--chrome", default=settings.CHROME_BINARY,
help="Specify Chrome Binary")
browser_group.add_argument("--chromium", default=settings.CHROMIUM_BINARY,
Expand Down
File renamed without changes.
File renamed without changes.
23 changes: 13 additions & 10 deletions src/bcfg/settings.py → bcfg/settings.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
from pathlib import Path

# Folder must exist. An absolute path to your download directory
DOWNLOAD_PATH = Path(r".")
# Leave the r that is before the quotes like r"" -- it's supposed to be there.
DOWNLOAD_PATH = r"."

# Use "chrome", "chromium", "firefox", "opera", "ie", "edge"
# I recommend using the most updated version official google chrome or chromium.
# Other browsers are not really tested.
# If one does not work try another. Updating your browser may help.
BROWSER = "chrome"
BROWSER = r"chrome"

# You only need one path to the binary (the executable file) named in the option BROWSER
# Try the command
# which google-chrome
# or whatever your command is for the browser (chromium-browser, firefox, etc)
# That path goes here. You can also find paths by right clicking and looking in properties of icons
# HINT: This probably won't be your path.
CHROME_BINARY = Path(r"C:\Program Files\Google\Chrome\Application\chrome.exe")
FIREFOX_BINARY = ""
CHROMIUM_BINARY = ""
EDGE_BINARY = ""
IE_BINARY = ""
OPERA_BINARY = ""
CHROME_BINARY = r"C:\Program Files\Google\Chrome\Application\chrome.exe"
CHROMIUM_BINARY = r""

# The path to a txt file where you will list bandcamp album urls to batch download.
ALBUM_LINKS_TXT = Path(r"C:\Users\x\PycharmProjects\bandcamp-flac-get\album_links.txt")
ALBUM_LINKS_TXT = r"./album_links.txt"

# Select one: Format options are "mp3" "mp3-vo" "mp3-320" "flac" "vorbis"
FORMAT = "mp3"
FORMAT = r"mp3"

# When bandcamp can't respond fast enough, how long should the browser wait before giving up?
# You can change this if you want.
TIMEOUT_TIME = 1000000000

# When you're done write out (CTRL+O) and exit (CTRL+X)

# Don't touch these
DOWNLOAD_PATH = Path(DOWNLOAD_PATH)
CHROME_BINARY = Path(CHROME_BINARY)
CHROMIUM_BINARY = Path(CHROMIUM_BINARY)
ALBUM_LINKS_TXT = Path(ALBUM_LINKS_TXT)
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = bandcamp-flac-get
version = 0.1
version = 1.0.1
author = shaenr
author_email = [email protected]
description = XXX
Expand All @@ -15,9 +15,9 @@ classifiers =
License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
[options]
package_dir =
= src
= .
packages = find:
python_requires = >=3.6

[options.packages.find]
where = src
where = .
File renamed without changes.
File renamed without changes.
Empty file removed src/__init__.py
Empty file.
1 change: 0 additions & 1 deletion utils/activate.cmd

This file was deleted.

2 changes: 1 addition & 1 deletion utils/bcfg-album2mkv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# USAGE:
# bash bcfg-album2mkv.sh infile.zip
# The $1 parameter should be a zip file of flacs generated by main.py/bcfg package or downloaded manually from bandcamp.
# The $1 parameter should be a zip file of flacs generated by bandcamp_flac_get.py/bcfg package or downloaded manually from bandcamp.

# WARRANTY:
# my script is provided as is and you should decide for yourself if you know how to use it.
Expand Down
1 change: 0 additions & 1 deletion utils/deactivate.cmd

This file was deleted.

0 comments on commit 83b123a

Please sign in to comment.