Skip to content

Commit

Permalink
Add script to build the app (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcrout authored May 19, 2020
1 parent e8663f8 commit 0d4609c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Directories
build/
css/
lib/
node_modules/
tubuler-darwin-x64/
venv/

# Files
app.spec
package-lock.json
src/download_video/__pycache__

Expand Down
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Pronouncing *tubuler* is similar to *tubular*, a term which was used by surfers

Using tubuler is easy: simply paste the YouTube video link into the app and click download. tubuler automatically chooses the best video and audio quality. The download time varies depending on the length of the video and its quality at which it was uploaded. tubuler can also work on other [video streaming sites](https://ytdl-org.github.io/youtube-dl/supportedsites.html).

tubuler is available for MacOS (*download coming soon*). Builds for Windows and Linux may be available in the future. You can also download this repo and build tubuler for your platform of choice (see [Building tubuler](#Building-tubular)).
## Releases

tubuler is available for MacOS (*download coming soon*). Builds for Windows and Linux may be available in the future. You can also download this repo and build tubuler for your platform of choice (see [Building tubuler](#Building-tubuler)).

## Development

Expand Down Expand Up @@ -46,7 +48,7 @@ tubuler is split into two different parts: the Electron front-end and the Flask

The front-end is developed in JavaScript [ES6](https://en.wikipedia.org/wiki/ECMAScript) to standardize development. The code which is developed on and the code which is used by Electron are separated into different directories. Development is done in `src/` and then transcribed into another directory `lib/` using [Babel](https://babeljs.io/). Looking into `package.json` can give more clarity into the development workflow.

The back-end is developed in Python using the [PEP-8](https://www.python.org/dev/peps/pep-0008/) standard. `npm run deps` creates a virtual environment `venv/` where all Python dependencies are contained. All Python source files are in the `src/download_video/` directory.
The back-end is developed in Python using [PEP-8](https://www.python.org/dev/peps/pep-0008/) formatting. `npm run deps` creates a virtual environment `venv/` where all Python dependencies are contained. All Python source files are in the `src/download_video/` directory.

The Flask app can be ran independently by running the following command in the root of the tubuler:

Expand All @@ -64,7 +66,19 @@ $ curl -X POST -H "Content-type: application/json" \

### Building tubuler

Coming soon...
The Flask app needs to be made into an executable before packaging tubuler. In `src/pythonProcess.js`, we need to comment/uncomment lines so we use the exectuable instead of the Python code. The beginning of `createPythonProcess()` should look like this:

```
// Run app using Python
// const script = path.join(__dirname, 'download_video', 'app.py');
// pyProcess = spawn('./venv/bin/python', [script]);
// Run app executable
const script = path.join(__dirname, 'download_video_dist', 'app', 'app');
pyProcess = execFile(script);
```

The app can then be built by running `npm run build`. This will create a directory containing the standalone tubuler app.

## Stack

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tubuler",
"version": "0.1.0",
"version": "1.0.0",
"description": "A simple front-end for youtube-dl.",
"repository": {
"type": "git",
Expand All @@ -9,9 +9,10 @@
"main": "lib/main.js",
"scripts": {
"babel": "babel src -d lib",
"build": "scripts/build.sh",
"clean": "scripts/clean.sh",
"deps": "scripts/make_python_env.sh",
"start": "npm run babel && cp -r src/download_video lib/download_video && electron ."
"start": "npm run babel && cp -r src/download_video lib/ && electron ."
},
"author": "Darshan Crout",
"license": "MIT",
Expand Down
18 changes: 18 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
npm install && \
npm run deps && \
npm run babel && \
cp -r node_modules/bulma/css . && \
cp -r src/download_video lib/ && \
pyinstaller src/download_video/app.py --distpath lib/download_video_dist && \
{
./node_modules/.bin/electron-packager . \
--ignore="lib/download_video/" \
--ignore="scripts" \
--ignore="src/" \
--ignore="venv/" \
--ignore=".babelrc" \
--ignore=".gitignore" \
--ignore="requirements.txt" \
--ignore="app.spec" \
--ignore="build/"
}
4 changes: 3 additions & 1 deletion scripts/clean.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
rm -rf css \
rm -rf app.spec \
build \
css \
lib \
node_modules \
package-lock.json \
Expand Down
8 changes: 0 additions & 8 deletions scripts/package.sh

This file was deleted.

3 changes: 3 additions & 0 deletions src/pythonProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { spawn, execFile } from 'child_process';
let pyProcess = null;

function createPythonProcess() {
// Run app using Python
const script = path.join(__dirname, 'download_video', 'app.py');
pyProcess = spawn('./venv/bin/python', [script]);

// Run app executable
// const script = path.join(__dirname, 'download_video_dist', 'app', 'app');
// pyProcess = execFile(script);

Expand Down

0 comments on commit 0d4609c

Please sign in to comment.