Skip to content

Commit

Permalink
Adds listener only feature
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymoulin committed Jan 17, 2021
1 parent d64260c commit aed271e
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all test publish install clean check build-docker publish-docker latest

VERSION ?= 1.0.0
VERSION ?= 1.1.0
CACHE ?= --no-cache=1
FULLVERSION ?= 1.6.3
archs ?= amd64 i386 arm64v8 arm32v6
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ First, launch the daemon to watch a directory new inputs.
Path to oauth file (default: ~/oauth)
-r, --remove Remove the file on your hard drive if it was already successfully uploaded (default: False)
-o, --oneshot Upload folder and exit (default: False)
-l, --listener_only Only listen for new files, does not parse all files at launch (default: False)
-w DEDUPLICATE_API, --deduplicate_api DEDUPLICATE_API
Deduplicate API (should be HTTP and compatible with
the manifest (see README)) (default: None)
Expand Down
7 changes: 4 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ COPY qemu-*-static /usr/bin/

FROM builder

ARG VERSION=1.0.0
ARG VERSION=1.1.0

LABEL maintainer="Jay MOULIN <jay@femtopixel.com> <https://twitter.com/MoulinJay>"
LABEL maintainer="Jay MOULIN <https://jaymoulin.me/me/youtube-music-uploader/> <https://twitter.com/MoulinJay>"
LABEL version=${VERSION}

ENV REMOVE=0
ENV ONESHOT=0
ENV DEDUP_API=
ENV LISTENER_ONLY=0
ENV DEDUP_API=''

RUN apk update && \
apk add gcc g++ linux-headers libxml2-dev libxslt-dev --no-cache --virtual .build-deps && \
Expand Down
1 change: 1 addition & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ These environments variable will produce a different behaviour

* `REMOVE` Remove file on a successful upload (boolean, (default: false)) - pass to true if you want to remove files
* `ONESHOT` Execute only once without listening to folder events (boolean, (default: false)) - pass to true if you want to execute only once (also remove `--restart=always` from docker parameters)
* `LISTENER_ONLY` Listener only, upload files only when added not at start (boolean, (default: false)) - pass to true if you want to listen
* `DEDUP_API` Url to the deduplicate API (string (default: None)) - Will call deduplicate API before trying to sample and upload to Google Music
* `LOGIN` Login (for cover art uploading) (string (default: None)) - Login of your Google Music account for cover art uploading
* `PASSWORD` Password (for cover art uploading) (string (default: None)) - Password of your Google Music account for cover art uploading
Expand Down
3 changes: 3 additions & 0 deletions docker/daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ else
if [[ "$ONESHOT" == "1" ]] || [[ "$ONESHOT" == "True" ]] || [[ "$ONESHOT" == "true" ]] || [[ "$ONESHOT" == "TRUE" ]]; then
PARAMS="$PARAMS -o"
fi
if [[ "$LISTENER_ONLY" == "1" ]] || [[ "$LISTENER_ONLY" == "True" ]] || [[ "$LISTENER_ONLY" == "true" ]] || [[ "$LISTENER_ONLY" == "TRUE" ]]; then
PARAMS="$PARAMS -l"
fi
if [[ "$DEDUP_API" ]]; then
PARAMS="$PARAMS -w $DEDUP_API"
fi
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ classifiers =
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Communications :: File Sharing
Topic :: Artistic Software
Topic :: Internet :: File Transfer Protocol (FTP)
Expand Down
2 changes: 1 addition & 1 deletion youtube_music_uploader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""

__all__ = ['uploader_daemon', '__version__']
__version__ = '1.0.0'
__version__ = '1.1.0'
15 changes: 12 additions & 3 deletions youtube_music_uploader/uploader_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def upload(
oauth: str = os.environ['HOME'] + '/oauth',
remove: bool = False,
oneshot: bool = False,
listerner_only: bool = False,
deduplicate_api: str = None,
) -> None:
handler = logging.StreamHandler()
Expand All @@ -133,9 +134,10 @@ def upload(
observer = Observer()
observer.schedule(event_handler, directory, recursive=True)
observer.start()
files = [file for file in glob.glob(glob.escape(directory) + '/**/*', recursive=True)]
for file_path in files:
upload_file(api, file_path, logger, remove=remove, deduplicate_api=deduplicate)
if not listerner_only:
files = [file for file in glob.glob(glob.escape(directory) + '/**/*', recursive=True)]
for file_path in files:
upload_file(api, file_path, logger, remove=remove, deduplicate_api=deduplicate)
if oneshot:
sys.exit(0)
try:
Expand Down Expand Up @@ -172,6 +174,12 @@ def main():
action='store_true',
help="Upload folder and exit (default: False)"
)
parser.add_argument(
"--listener_only",
'-l',
action='store_true',
help="Only listen for new files, does not parse all files at launch (default: False)"
)
parser.add_argument(
"--deduplicate_api",
'-w',
Expand All @@ -193,6 +201,7 @@ def main():
oauth=args.oauth,
remove=args.remove,
oneshot=args.oneshot,
listerner_only=args.listener_only,
deduplicate_api=args.deduplicate_api,
)

Expand Down

0 comments on commit aed271e

Please sign in to comment.