Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running tool as package or script #7

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ check-env:
docker-compose run app python3.6 src/check_env.py

get-google-refresh-token:
docker-compose run app python3.6 src/get_google_refresh_token.py
docker-compose run app python3.6 src/get_google_refresh_token.py

prepare-pipenv:
pip install pipenv
pipenv install --dev

sync-setup-py: prepare-pipenv
pipenv run pipenv-setup sync
17 changes: 17 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
requests = "==2.20.0"
python-dotenv = "==0.6.4"
google-api-python-client = "==1.6.2"
httplib2 = "*"
PyJWT = "*"

[dev-packages]
pipenv-setup = "*"

[requires]
python_version = "3.8"
477 changes: 477 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,25 @@ Another way to run the app, through virtualenv
$ sudo service cron restart
```

Yet another way to run the app, as a package
------------------------------------------------------------------------

1. Use an virtualenv or isolation tactic you prefer
2. Install as a package
```
$ pip install git+https://github.com/patcon/Zoom2YouTube.git@packaged#egg=zoom2youtube
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge this before accepting PR :)

Suggested change
$ pip install git+https://github.com/patcon/Zoom2YouTube.git@packaged#egg=zoom2youtube
$ pip install git+https://github.com/Welltory/Zoom2YouTube.git@master#egg=zoom2youtube

```
3. Export any required envvars directly
```
$ export ZOOM_API_KEY=xxxxx
$ export ZOOM_API_SECRET=xxxxx
...
```
4. Run the command
```
$ zoom2youtube
```

Sample .env file
-----------------

Expand Down
2 changes: 1 addition & 1 deletion cron/crontab
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*/5 * * * * /usr/local/bin/python3.7 /opt/app/src/main.py >> /var/log/cron.log 2>&1
*/5 * * * * /usr/local/bin/python3.7 /opt/app/src/zoom2youtube/main.py >> /var/log/cron.log 2>&1
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta:__legacy__"
39 changes: 39 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from os.path import splitext, basename

from glob import glob
from setuptools import setup, find_packages

setup(
install_requires=[
"certifi==2020.12.5",
"chardet==3.0.4",
"click==7.1.2; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"google-api-python-client==1.6.2",
"httplib2==0.19.1",
"idna==2.7",
"oauth2client==4.1.3",
"pyasn1==0.4.8",
"pyasn1-modules==0.2.8",
"pyjwt==2.1.0",
"pyparsing==2.4.7; python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"python-dotenv==0.6.4",
"requests==2.20.0",
"rsa==4.7.2; python_version >= '3.5' and python_version < '4'",
"six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"uritemplate==3.0.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"urllib3==1.24.3; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' and python_version < '4'",
],
name="zoom2youtube",
version="0.0.1",
description="Transfer video recordings from the Zoom to YouTube",
url="https://github.com/Welltory/Zoom2Youtube/",
author="Welltory",
author_email="[email protected]",
license="MIT",
packages=find_packages("src"),
package_dir={"": "src"},
include_package_data=True,
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
entry_points={"console_scripts": ["zoom2youtube=zoom2youtube.main:main",],},
zip_safe=False,
)
2 changes: 2 additions & 0 deletions src/zoom2youtube/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import os, sys
sys.path.append(os.path.dirname(__file__))
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 5 additions & 1 deletion src/main.py → src/zoom2youtube/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
os.remove(self._lock_file)


if __name__ == '__main__':
def main():
with lock(LOCK_FILE):
print('Start...')
# download videos from zoom
Expand Down Expand Up @@ -75,3 +75,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
)
youtube.upload_from_dir(VIDEO_DIR)
print('End.')


if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions src/settings.py → src/zoom2youtube/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
ZOOM_API_KEY = os.environ.get("ZOOM_API_KEY")
ZOOM_API_SECRET = os.environ.get("ZOOM_API_SECRET")
ZOOM_FROM_DAY_DELTA = int(os.environ.get("ZOOM_FROM_DAY_DELTA") or 7)
ZOOM_PAGE_SIZE = int(os.environ.get("ZOOM_PAGE_SIZE") or 10)

VIDEO_DIR = join(BASE_DIR, 'video')

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/zoom.py → src/zoom2youtube/zoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_meetings(self):
uri = "users/{}/recordings?from={}&page_size={}".format(
self.email,
(datetime.utcnow() - timedelta(days=self.from_day_delta)).strftime("%Y-%m-%d"),
page_size
self.page_size
)
resp = self.client.get(uri)
if resp.status_code != 200:
Expand Down