Skip to content

Commit

Permalink
Merge pull request #18 from martynvdijke/develop
Browse files Browse the repository at this point in the history
Release v/0.4.0
  • Loading branch information
martynvdijke authored Jun 26, 2024
2 parents d49470b + 70abeed commit ecb5b77
Show file tree
Hide file tree
Showing 20 changed files with 2,321 additions and 432 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ lib
lib64
*.pyc
*.pyo
youtube_playlist_randomizer/__pycache_/*
youtube_playlist_randomizer/__pycache_/*
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

34 changes: 0 additions & 34 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/inspectionProfiles/profiles_settings.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

11 changes: 0 additions & 11 deletions .idea/youtube-playlist-randomizer.iml

This file was deleted.

1,865 changes: 1,865 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

51 changes: 31 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
[build-system]
requires = ["flit_core >=2,<4"]
build-backend = "flit_core.buildapi"
[tool.poetry]
name = "youtube-playlist-randomizer"
version = "0.4.0"
description = "A tool to randomize youtube playlists"
authors = ["Martyn van Dijke <[email protected]>"]
license = "MIT"
readme = "README.md"
packages = [{include = "youtube_playlist_randomizer"}]

[tool.poetry.dependencies]
python = "^3.11"
google-api-python-client = "^2.134.0"
prompt-toolkit2 = "^2.0.11"
google-auth-oauthlib = "^1.2.0"
prompt-toolkit = "^3.0.47"


[tool.flit.metadata]
module = "youtube_playlist_randomizer"
author = "Martyn van Dijke"
author-email = "[email protected]"
home-page = "https://github.com/martynvdijke/youtube-playlist-randomizer"
requires=[
"flit_core>=2.2.0",
"coloredlogs",
"google_auth_oauthlib",
"google-api-python-client",
"prompt_toolkit"
]
requires-python=">=3.5"
classifiers = [ "License :: OSI Approved :: MIT License",]
description-file = "README.md"
[tool.poetry.group.dev.dependencies]
pylint = "^2.17.7"
black = "^23.12.1"
mypy = "^1.10.1"
pytest = "^7.4.4"
flake8 = "^6.1.0"
ruff = "^0.4.10"
poetry = "^1.8.3"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.flit.scripts]
youtube_playlist_randomizer = "youtube_playlist_randomizer:main"
[tool.poetry.scripts]
youtube-playlist-randomizer = 'youtube_playlist_randomizer.main:main'
ypr = 'youtube_playlist_randomizer.main:main'
21 changes: 0 additions & 21 deletions tox.ini

This file was deleted.

99 changes: 1 addition & 98 deletions youtube_playlist_randomizer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,103 +1,6 @@
"""
Simple python cli script to shuffle an input list and save the playlist
"""

__version__ = "0.2.0"

"""
Main module for
"""
import argparse
import logging
import sys
import pathlib
import coloredlogs
from . import __version__
from . import auth
from . import playlist

__author__ = "Martyn van Dijke"
__copyright__ = "Martyn van Dijke"
__license__ = "MIT"
_logger = logging.getLogger(__name__)


def parse_args(args):
"""
Args:
args: cli arguments given to script
Returns:
list of supported arguments
"""
parser = argparse.ArgumentParser(description="Playlist randomizer")
parser.add_argument(
"--version",
action="version",
version=f"randomizer version: {__version__}",
)

# set logging level
parser.add_argument(
"-v",
"--verbose",
dest="loglevel",
help="set loglevel to INFO",
action="store_const",
const=logging.INFO,
)
parser.add_argument(
"-vv",
"--very-verbose",
dest="loglevel",
help="set loglevel to DEBUG",
action="store_const",
const=logging.DEBUG,
)

parser.add_argument(
"-n",
"--update_request",
default=190,
help="Specify the number of update request to do per 24 hours [default=%(default)r]",
)

parser.add_argument(
"-i",
"--input",
default="client_secret.json",
type=pathlib.Path,
help="Specify the secret client json file [default=%(default)r]",
required=True,
)
return parser.parse_args(args)


def setup_logging(loglevel):
"""Setup basic logging
Args:
loglevel (int): minimum loglevel for emitting messages
"""
logformat = "[%(asctime)s] %(levelname)s:%(name)s:%(message)s"
logging.basicConfig(
level=loglevel,
stream=sys.stdout,
format=logformat,
datefmt="%Y-%m-%d %H:%M:%S",
)
# setup colred logs
coloredlogs.install(level=loglevel, logger=_logger)


def main(argv=None):
"""
Main function that does all the dispatching of the subfunctions
Args:
args: sys arguments
Returns:
none
"""
args = parse_args(argv)
setup_logging(args.loglevel)
youtube = auth.auth(args)
playlist.PlayListRandomizer(youtube, args)
sys.exit("Done shuffling playlist, thank for using")
__version__ = "0.3.0"
3 changes: 0 additions & 3 deletions youtube_playlist_randomizer/__main__.py

This file was deleted.

72 changes: 72 additions & 0 deletions youtube_playlist_randomizer/arg_parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@


from youtube_playlist_randomizer import __version__
import argparse
import logging
import pathlib
import sys


def parse_args():
"""
Returns:
list of supported arguments
"""
parser = argparse.ArgumentParser(description="Playlist randomizer")
parser.add_argument(
"--version",
action="version",
version=f"randomizer version: {__version__}",
)

# set logging level
parser.add_argument(
"-v",
"--verbose",
dest="loglevel",
help="set loglevel to INFO",
action="store_const",
const=logging.INFO,
)
parser.add_argument(
"-vv",
"--very-verbose",
dest="loglevel",
help="set loglevel to DEBUG",
action="store_const",
const=logging.DEBUG,
)

parser.add_argument(
"-n",
"--number_of",
dest="chunks",
default=190,
help="Specify the number of update request to do per 24 hours [default=%(default)r]",
)

parser.add_argument(
"-i",
"--input",
default="client_secret.json",
dest="input",
type=pathlib.Path,
help="Specify the secret client json file [default=%(default)r]",
required=False,
)
return parser.parse_args()


def setup_logging(loglevel):
"""Setup basic logging
Args:
loglevel (int): minimum loglevel for emitting messages
"""
logformat = "[%(asctime)s] %(levelname)s:%(name)s:%(message)s"
logging.basicConfig(
level=loglevel,
stream=sys.stdout,
format=logformat,
datefmt="%Y-%m-%d %H:%M:%S",
)

14 changes: 6 additions & 8 deletions youtube_playlist_randomizer/auth.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Authenticate teh user for youtube client
Authenticate the users to youtube.
"""

import os
Expand All @@ -11,7 +11,7 @@
scopes = ["https://www.googleapis.com/auth/youtube.force-ssl"]


def auth(args):
def auth(file):
"""
Autehnticates the user to acces the users youtube content
:param args: sys arguments
Expand All @@ -23,14 +23,12 @@ def auth(args):

api_service_name = "youtube"
api_version = "v3"
client_secrets_file = args.input
client_secrets_file = file

# Get credentials and create an API client
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
client_secrets_file, scopes
)
credentials = flow.run_console()
client_secrets_file, scopes)
credentials = flow.run_local_server()
youtube = googleapiclient.discovery.build(
api_service_name, api_version, credentials=credentials
)
api_service_name, api_version, credentials=credentials)
return youtube
Loading

0 comments on commit ecb5b77

Please sign in to comment.