├── .eslintrc.json ├── .github └── workflows │ ├── build.yml │ └── create-release-from-changelog.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── doc ├── activity.png ├── settings.png └── start-synchronizing.png ├── entitlements.plist ├── forge.config.js ├── package-lock.json ├── package.json ├── src ├── activity-client.ts ├── activity-window.ts ├── assets │ ├── Logo_white_text.svg │ ├── activity.html │ ├── api-video-logo.icns │ ├── api-video-logo.ico │ ├── green-dot.png │ ├── orange-dot.png │ ├── settings.html │ ├── styles.css │ └── tray-icon.png ├── index.ts ├── settings-client.ts ├── settings-window.ts ├── synchronizer.ts └── tools.ts ├── tsconfig.json └── yarn.lock /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true, 4 | "es6": true, 5 | "node": true 6 | }, 7 | "extends": [ 8 | "eslint:recommended", 9 | "plugin:@typescript-eslint/eslint-recommended", 10 | "plugin:@typescript-eslint/recommended", 11 | "plugin:import/recommended", 12 | "plugin:import/electron", 13 | "plugin:import/typescript" 14 | ], 15 | "parser": "@typescript-eslint/parser" 16 | } 17 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | on: 3 | release: 4 | types: [published] 5 | jobs: 6 | build-macos: 7 | runs-on: macos-latest 8 | steps: 9 | - name: Check out Git repository 10 | uses: actions/checkout@v1 11 | 12 | - name: Add Apple developer ID certificate 13 | env: 14 | MACOS_CERTIFICATE: ${{ secrets.APPLE_DEVELOPER_ID_CERTIFICATE }} 15 | MACOS_CERTIFICATE_PWD: ${{ secrets.APPLE_DEVELOPER_ID_CERTIFICATE_PASSWORD }} 16 | run: | 17 | echo $MACOS_CERTIFICATE > certificate.base64 18 | base64 -i certificate.base64 --decode > certificate.p12 19 | security create-keychain -p TMP_KEYCHAIN_PASS build.keychain 20 | security default-keychain -s build.keychain 21 | security unlock-keychain -p TMP_KEYCHAIN_PASS build.keychain 22 | security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign 23 | security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k TMP_KEYCHAIN_PASS build.keychain 24 | - name: Install Node.js, NPM and Yarn 25 | uses: actions/setup-node@v1 26 | with: 27 | node-version: 14 28 | 29 | - name: Build/release Electron app 30 | run: npm install && npm run make && cp out/make/zip/darwin/x64/api-video-darwin-x64-*.zip out/make/api-video.zip 31 | env: 32 | APPLE_ID: ${{ secrets.APPLE_ID }} 33 | APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }} 34 | 35 | - uses: actions/upload-artifact@v2 36 | with: 37 | name: api-video.dmg 38 | path: out/make/api-video.dmg 39 | 40 | - uses: actions/upload-artifact@v2 41 | with: 42 | name: api-video.zip 43 | path: out/make/api-video.zip 44 | build-windows: 45 | runs-on: windows-latest 46 | steps: 47 | - name: Check out Git repository 48 | uses: actions/checkout@v1 49 | 50 | - name: Install Node.js, NPM and Yarn 51 | uses: actions/setup-node@v1 52 | with: 53 | node-version: 14 54 | 55 | - name: Build/release Electron app 56 | run: npm install && npm run make 57 | 58 | - uses: actions/upload-artifact@v2 59 | with: 60 | name: api-video-win32-x64-setup.exe 61 | path: out/make/squirrel.windows/x64/api-video-win32-x64-setup.exe 62 | release: 63 | name: Upload Release Asset 64 | needs: [build-macos, build-windows] 65 | runs-on: ubuntu-latest 66 | steps: 67 | - uses: actions/download-artifact@v2 68 | with: 69 | name: api-video.dmg 70 | - uses: actions/download-artifact@v2 71 | with: 72 | name: api-video.zip 73 | - uses: actions/download-artifact@v2 74 | with: 75 | name: api-video-win32-x64-setup.exe 76 | - name: ls 77 | run: ls 78 | - name: Upload macos zip to release 79 | uses: svenstaro/upload-release-action@v2 80 | with: 81 | repo_token: ${{ secrets.GITHUB_TOKEN }} 82 | file: ./api-video.zip 83 | asset_name: api-video-${{ github.ref_name }}-darwin-x64.zip 84 | tag: ${{ github.ref }} 85 | overwrite: true 86 | - name: Upload macos binaries to release 87 | uses: svenstaro/upload-release-action@v2 88 | with: 89 | repo_token: ${{ secrets.GITHUB_TOKEN }} 90 | file: ./api-video.dmg 91 | asset_name: api-video-${{ github.ref_name }}-darwin-x64.dmg 92 | tag: ${{ github.ref }} 93 | overwrite: true 94 | - name: Upload windows binaries to release 95 | uses: svenstaro/upload-release-action@v2 96 | with: 97 | repo_token: ${{ secrets.GITHUB_TOKEN }} 98 | file: ./api-video-win32-x64-setup.exe 99 | asset_name: api-video-${{ github.ref_name }}-win32-x64-setup.exe 100 | tag: ${{ github.ref }} 101 | overwrite: true -------------------------------------------------------------------------------- /.github/workflows/create-release-from-changelog.yml: -------------------------------------------------------------------------------- 1 | name: Create draft release from CHANGELOG.md 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'CHANGELOG.md' 7 | 8 | jobs: 9 | update-documentation: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: Create draft release if needed 14 | uses: apivideo/api.video-release-from-changelog-action@main 15 | with: 16 | github-auth-token: ${{ secrets.GITHUB_TOKEN }} 17 | prefix: v 18 | 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | .DS_Store 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # TypeScript cache 43 | *.tsbuildinfo 44 | 45 | # Optional npm cache directory 46 | .npm 47 | 48 | # Optional eslint cache 49 | .eslintcache 50 | 51 | # Optional REPL history 52 | .node_repl_history 53 | 54 | # Output of 'npm pack' 55 | *.tgz 56 | 57 | # Yarn Integrity file 58 | .yarn-integrity 59 | 60 | # dotenv environment variables file 61 | .env 62 | .env.test 63 | 64 | # parcel-bundler cache (https://parceljs.org/) 65 | .cache 66 | 67 | # next.js build output 68 | .next 69 | 70 | # nuxt.js build output 71 | .nuxt 72 | 73 | # vuepress build output 74 | .vuepress/dist 75 | 76 | # Serverless directories 77 | .serverless/ 78 | 79 | # FuseBox cache 80 | .fusebox/ 81 | 82 | # DynamoDB Local files 83 | .dynamodb/ 84 | 85 | # Webpack 86 | .webpack/ 87 | 88 | # Electron-Forge 89 | out/ 90 | dist 91 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | All changes to this project will be documented in this file. 3 | 4 | ## [0.1.2] - 2021-12-20 5 | - Add auto-update feature 6 | - Build MacOS zip bundle 7 | 8 | ## [0.1.1] - 2021-12-20 9 | - Fix tray icon size 10 | - Change executable file name 11 | 12 | ## [0.1.0] - 2021-12-20 13 | - Add "video uploaded" notification 14 | 15 | ## [0.0.2] - 2021-12-10 16 | - Rename "DONE" label to "VIEW" 17 | - Restart downloads that have failed 18 | - Improve activity window design 19 | 20 | ## [0.0.1] - 2021-12-09 21 | - First alpha version 22 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to api.video 2 | 3 | :movie_camera::+1::tada: Thank you for taking the time to contribute and participate in the implementation of a Video First World! :tada::+1::movie_camera: 4 | 5 | The following is a set of guidelines for contributing to api.video and its packages, which are hosted in the [api.video Organization](https://github.com/apivideo) on GitHub. 6 | 7 | #### Table of contents 8 | 9 | - [Contributing to api.video](#contributing-to-apivideo) 10 | - [Table of contents](#table-of-contents) 11 | - [Code of conduct](#code-of-conduct) 12 | - [I just have a question!](#i-just-have-a-question) 13 | - [How can I contribute?](#how-can-i-contribute) 14 | - [Reporting bugs](#reporting-bugs) 15 | - [Before submitting a bug report](#before-submitting-a-bug-report) 16 | - [How do I submit a (good) bug report?](#how-do-i-submit-a-good-bug-report) 17 | - [Suggesting enhancements](#suggesting-enhancements) 18 | - [How do I submit a (good) enhancement suggestion?](#how-do-i-submit-a-good-enhancement-suggestion) 19 | - [Pull requests](#pull-requests) 20 | - [Style guides](#style-guides) 21 | - [Git commit messages](#git-commit-messages) 22 | - [Documentation style guide](#documentation-style-guide) 23 | - [Additional notes](#additional-notes) 24 | - [Issue and pull request labels](#issue-and-pull-request-labels) 25 | - [Type of issue and issue state](#type-of-issue-and-issue-state) 26 | - [Topic categories](#topic-categories) 27 | - [Pull request labels](#pull-request-labels) 28 | 29 | ## Code of conduct 30 | 31 | This project and everyone participating in it is governed by the [api.video Code of Conduct](https://github.com/apivideo/.github/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [help@api.video](mailto:help@api.video). 32 | 33 | ## I just have a question! 34 | 35 | > **Note:** [Please don't file an issue to ask a question.] You'll get faster results by using the resources below. 36 | 37 | We have an official message board with a detailed FAQ and where the community chimes in with helpful advice if you have questions. 38 | 39 | * [The official api.video's Community](https://community.api.video/) 40 | * [api.video FAQ](https://community.api.video/c/faq/) 41 | 42 | 43 | ## How can I contribute? 44 | 45 | ### Reporting bugs 46 | 47 | This section guides you through submitting a bug report for api.video. Following these guidelines helps maintainers and the community understand your report :pencil:, reproduce the behavior :computer:, and find related reports :mag_right:. 48 | 49 | Before creating bug reports, please check [this list](#before-submitting-a-bug-report) as you might find out that you don't need to create one. When you are creating a bug report, please [include as many details as possible](#how-do-i-submit-a-good-bug-report). Fill out [the required template](https://github.com/apivideo/.github/blob/main/.github/ISSUE_TEMPLATE/bug_report.yml), the information it asks for helps us resolve issues faster. 50 | 51 | > **Note:** If you find a **Closed** issue that seems like it is the same thing that you're experiencing, open a new issue and include a link to the original issue in the body of your new one. 52 | 53 | #### Before submitting a bug report 54 | 55 | * **Check the [The official api.video's Community](https://community.api.video/)** for a list of common questions and problems. 56 | * **Determine which repository the problem should be reported in**. 57 | * **Perform a [cursory search](https://github.com/search?q=is%3Aissue+user%3Aapivideo)** to see if the problem has already been reported. If it has **and the issue is still open**, add a comment to the existing issue instead of opening a new one. 58 | 59 | #### How do I submit a (good) bug report? 60 | 61 | Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined which repository your bug is related to, create an issue on that repository and provide the following information by filling in [the template](https://github.com/apivideo/.github/blob/main/.github/ISSUE_TEMPLATE/bug_report.yml). 62 | 63 | Explain the problem and include additional details to help maintainers reproduce the problem: 64 | 65 | * **Use a clear and descriptive title** for the issue to identify the problem. 66 | * **Describe the exact steps which reproduce the problem** in as many details as possible. When listing steps, **don't just say what you did, but explain how you did it**. 67 | * **Provide specific examples to demonstrate the steps**. Include links to files or GitHub projects, or copy/pasteable snippets, which you use in those examples. If you're providing snippets in the issue, use [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). 68 | * **Describe the behavior you observed after following the steps** and point out what exactly is the problem with that behavior. 69 | * **Explain which behavior you expected to see instead and why.** 70 | * **Include screenshots or videos** which show you following the described steps and clearly demonstrate the problem. 71 | * **If the problem wasn't triggered by a specific action**, describe what you were doing before the problem happened and share more information using the guidelines below. 72 | 73 | Provide more context by answering these questions: 74 | 75 | * **Did the problem start happening recently** (e.g. after updating to a new version of api.video) or was this always a problem? 76 | * If the problem started happening recently.** 77 | * **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens. 78 | 79 | Include details about your configuration and environment: 80 | 81 | * **Which version of the api.video package are you using?** 82 | * **What's the name and version of the OS you're using?** 83 | 84 | ### Suggesting enhancements 85 | 86 | This section guides you through submitting an enhancement suggestion for api.video project, including completely new features and minor improvements to existing functionality. Following these guidelines helps maintainers and the community understand your suggestion :pencil: and find related suggestions :mag_right:. 87 | 88 | When you are creating an enhancement suggestion, please [include as many details as possible](#how-do-i-submit-a-good-enhancement-suggestion). Fill in [the template](https://github.com/apivideo/.github/blob/main/.github/ISSUE_TEMPLATE/feature_request.yml), including the steps that you imagine you would take if the feature you're requesting existed. 89 | 90 | 91 | #### How do I submit a (good) enhancement suggestion? 92 | 93 | Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). After you've determined which repository your enhancement suggestion is related to, create an issue on that repository and provide the following information: 94 | 95 | * **Use a clear and descriptive title** for the issue to identify the suggestion. 96 | * **Provide a step-by-step description of the suggested enhancement** in as many details as possible. 97 | * **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets which you use in those examples, as [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines). 98 | * **Describe the current behavior** and **explain which behavior you expected to see instead** and why. 99 | * **Include screenshots** which help you demonstrate the steps or point out the part of api.video which the suggestion is related to. 100 | * **Explain why this enhancement would be useful** to most api.video users and isn't something that can or should be implemented as a community package. 101 | * **Specify which version of the api.video package you're using.** 102 | * **Specify the name and version of the OS you're using.** 103 | 104 | 105 | ### Pull requests 106 | 107 | The process described here has several goals: 108 | 109 | - Maintain api.video's quality 110 | - Fix problems that are important to users 111 | - Engage the community in working toward the best possible api.video 112 | - Enable a sustainable system for api.video's maintainers to review contributions 113 | 114 | Please follow these steps to have your contribution considered by the maintainers: 115 | 116 | 1. Explain what, why and how you resolved the issue. If you have a related issue, please mention it. 117 | 2. Follow the [style guides](#style-guides) 118 | 3. After you submit your pull request, verify that all [status checks](https://help.github.com/articles/about-status-checks/) are passing
What if the status checks are failing?If a status check is failing, and you believe that the failure is unrelated to your change, please leave a comment on the pull request explaining why you believe the failure is unrelated. A maintainer will re-run the status check for you. If we conclude that the failure was a false positive, then we will open an issue to track that problem with our status check suite.
119 | 120 | While the prerequisites above must be satisfied prior to having your pull request reviewed, the reviewer(s) may ask you to complete additional design work, tests, or other changes before your pull request can be ultimately accepted. 121 | 122 | ## Style guides 123 | 124 | ### Git commit messages 125 | 126 | * Use the present tense ("Add feature" not "Added feature") 127 | * Limit the first line to 72 characters or less 128 | * Reference issues and pull requests after the first line 129 | * Consider starting the commit message with an applicable emoji: 130 | * :art: `:art:` when improving the format/structure of the code 131 | * :racehorse: `:racehorse:` when improving performance 132 | * :non-potable_water: `:non-potable_water:` when plugging memory leaks 133 | * :memo: `:memo:` when writing docs 134 | * :penguin: `:penguin:` when fixing something on Linux 135 | * :apple: `:apple:` when fixing something on macOS 136 | * :checkered_flag: `:checkered_flag:` when fixing something on Windows 137 | * :bug: `:bug:` when fixing a bug 138 | * :fire: `:fire:` when removing code or files 139 | * :green_heart: `:green_heart:` when fixing the CI build 140 | * :white_check_mark: `:white_check_mark:` when adding tests 141 | * :lock: `:lock:` when dealing with security 142 | * :arrow_up: `:arrow_up:` when upgrading dependencies 143 | * :arrow_down: `:arrow_down:` when downgrading dependencies 144 | * :shirt: `:shirt:` when removing linter warnings 145 | 146 | ### Documentation style guide 147 | 148 | * Use [Markdown](https://daringfireball.net/projects/markdown). 149 | 150 | 151 | ## Additional notes 152 | 153 | ### Issue and pull request labels 154 | 155 | This section lists the labels we use to help us track and manage issues and pull requests on all api.video repositories. 156 | 157 | [GitHub search](https://help.github.com/articles/searching-issues/) makes it easy to use labels for finding groups of issues or pull requests you're interested in. We encourage you to read about [other search filters](https://help.github.com/articles/searching-issues/) which will help you write more focused queries. 158 | 159 | 160 | #### Type of issue and issue state 161 | 162 | | Label name | `apivideo` :mag_right: | Description | 163 | | --- | --- | --- | 164 | | `enhancement` | [search][search-apivideo-org-label-enhancement] | Feature requests. | 165 | | `bug` | [search][search-apivideo-org-label-bug] | Confirmed bugs or reports that are very likely to be bugs. | 166 | | `question` | [search][search-apivideo-org-label-question] | Questions more than bug reports or feature requests (e.g. how do I do X). | 167 | | `feedback` | [search][search-apivideo-org-label-feedback] | General feedback more than bug reports or feature requests. | 168 | | `help-wanted` | [search][search-apivideo-org-label-help-wanted] | The api.video team would appreciate help from the community in resolving these issues. | 169 | | `more-information-needed` | [search][search-apivideo-org-label-more-information-needed] | More information needs to be collected about these problems or feature requests (e.g. steps to reproduce). | 170 | | `needs-reproduction` | [search][search-apivideo-org-label-needs-reproduction] | Likely bugs, but haven't been reliably reproduced. | 171 | | `blocked` | [search][search-apivideo-org-label-blocked] | Issues blocked on other issues. | 172 | | `duplicate` | [search][search-apivideo-org-label-duplicate] | Issues which are duplicates of other issues, i.e. they have been reported before. | 173 | | `wontfix` | [search][search-apivideo-org-label-wontfix] | The api.video team has decided not to fix these issues for now, either because they're working as intended or for some other reason. | 174 | | `invalid` | [search][search-apivideo-org-label-invalid] | Issues which aren't valid (e.g. user errors). | 175 | | `package-idea` | [search][search-apivideo-org-label-package-idea] | Feature request which might be good candidates for new packages, instead of extending api.video packages. | 176 | | `wrong-repo` | [search][search-apivideo-org-label-wrong-repo] | Issues reported on the wrong repository. | 177 | 178 | #### Topic categories 179 | 180 | | Label name | `apivideo` :mag_right: | Description | 181 | | --- | --- | --- | 182 | | `windows` | [search][search-apivideo-org-label-windows] | Related to api.video running on Windows. | 183 | | `linux` | [search][search-apivideo-org-label-linux] | Related to api.video running on Linux. | 184 | | `mac` | [search][search-apivideo-org-label-mac] | Related to api.video running on macOS. | 185 | | `documentation` | [search][search-apivideo-org-label-documentation] | Related to any type of documentation. | 186 | | `performance` | [search][search-apivideo-org-label-performance] | Related to performance. | 187 | | `security` | [search][search-apivideo-org-label-security] | Related to security. | 188 | | `ui` | [search][search-apivideo-org-label-ui] | Related to visual design. | 189 | | `api` | [search][search-apivideo-org-label-api] | Related to api.video's public APIs. | 190 | 191 | #### Pull request labels 192 | 193 | | Label name | `apivideo` :mag_right: | Description 194 | | --- | --- | --- | 195 | | `work-in-progress` | [search][search-apivideo-org-label-work-in-progress] | Pull requests which are still being worked on, more changes will follow. | 196 | | `needs-review` | [search][search-apivideo-org-label-needs-review] | Pull requests which need code review, and approval from maintainers or api.video team. | 197 | | `under-review` | [search][search-apivideo-org-label-under-review] | Pull requests being reviewed by maintainers or api.video team. | 198 | | `requires-changes` | [search][search-apivideo-org-label-requires-changes] | Pull requests which need to be updated based on review comments and then reviewed again. | 199 | | `needs-testing` | [search][search-apivideo-org-label-needs-testing] | Pull requests which need manual testing. | 200 | 201 | [search-apivideo-org-label-enhancement]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aenhancement 202 | [search-apivideo-org-label-bug]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Abug 203 | [search-apivideo-org-label-question]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aquestion 204 | [search-apivideo-org-label-feedback]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Afeedback 205 | [search-apivideo-org-label-help-wanted]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Ahelp-wanted 206 | [search-apivideo-org-label-more-information-needed]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Amore-information-needed 207 | [search-apivideo-org-label-needs-reproduction]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aneeds-reproduction 208 | [search-apivideo-org-label-windows]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Awindows 209 | [search-apivideo-org-label-linux]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Alinux 210 | [search-apivideo-org-label-mac]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Amac 211 | [search-apivideo-org-label-documentation]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Adocumentation 212 | [search-apivideo-org-label-performance]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aperformance 213 | [search-apivideo-org-label-security]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Asecurity 214 | [search-apivideo-org-label-ui]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aui 215 | [search-apivideo-org-label-api]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aapi 216 | [search-apivideo-org-label-blocked]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Ablocked 217 | [search-apivideo-org-label-duplicate]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Aduplicate 218 | [search-apivideo-org-label-wontfix]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Awontfix 219 | [search-apivideo-org-label-invalid]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Ainvalid 220 | [search-apivideo-org-label-package-idea]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Apackage-idea 221 | [search-apivideo-org-label-wrong-repo]: https://github.com/search?q=is%3Aopen+is%3Aissue+user%3Aapivideo+label%3Awrong-repo 222 | [search-apivideo-org-label-work-in-progress]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Awork-in-progress 223 | [search-apivideo-org-label-needs-review]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Aneeds-review 224 | [search-apivideo-org-label-under-review]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Aunder-review 225 | [search-apivideo-org-label-requires-changes]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Arequires-changes 226 | [search-apivideo-org-label-needs-testing]: https://github.com/search?q=is%3Aopen+is%3Apr+repo%3Aapivideo%2Fapivideo+label%3Aneeds-testing 227 | 228 | [help-wanted]:https://github.com/search?q=is%3Aopen+is%3Aissue+label%3Ahelp-wanted+user%3Aapivideo+sort%3Acomments-desc 229 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 api.video 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![badge](https://img.shields.io/twitter/follow/api_video?style=social)](https://twitter.com/intent/follow?screen_name=api_video)   [![badge](https://img.shields.io/github/stars/apivideo/api.video-desktop-synchronizer?style=social)](https://github.com/apivideo/api.video-desktop-synchronizer)   [![badge](https://img.shields.io/discourse/topics?server=https%3A%2F%2Fcommunity.api.video)](https://community.api.video) 2 | ![](https://github.com/apivideo/.github/blob/main/assets/apivideo_banner.png) 3 |

api.video video synchronization desktop application

4 | 5 | [api.video](https://api.video) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app. 6 | 7 | # Table of contents 8 | - [Table of contents](#table-of-contents) 9 | - [Warning](#warning) 10 | - [Project description](#project-description) 11 | - [Getting started](#getting-started) 12 | - [Requirements](#requirements) 13 | - [Installation & first run](#installation--first-run) 14 | - [Documentation](#documentation) 15 | - [What is meant by "synchronization"](#what-is-meant-by-synchronization) 16 | 17 | # Warning 18 | 19 | **This project is still in the testing phase. The applications proposed for download should be considered as alpha version.** 20 | 21 | # Project description 22 | 23 | This desktop application allows you to easily upload all the videos files stored in a given folder of your computer to api.video. 24 | 25 | # Getting started 26 | 27 | 28 | ## Requirements 29 | 30 | At the moment, the application is compatible with MacOS & Windows. 31 | 32 | ## Installation & first run 33 | 34 | 1) download the executable that matches your OS (currently MacOS & Windows are supported) here: [latest release](https://github.com/apivideo/api.video-desktop-synchronizer/releases/latest). 35 | 2) launch the executable (NOTE: at the moment, Windows executables are not signed, so you will probably have to accept some security warnings at the first run) 36 | 3) when you launch the app for the first time, the Settings window appears. Here, you'll have to enter your [api.video API key](https://dashboard.api.video/register), and the folder you want to watch: 37 | 38 | ![](doc/settings.png) 39 | 40 | 4) once done, click on `Apply`. You can now lauch the synchronization by clicking on the api.video icon in your tray icons (next to the clock), and then on `Start synchronizing`: 41 | 42 | ![](doc/start-synchronizing.png) 43 | 44 | 5) To see what files have been or are beeing uploaded, click on `Activity`. You'll see the upload progress of all your uploads: 45 | 46 | ![](doc/activity.png) 47 | 48 | # Documentation 49 | 50 | ## What is meant by "synchronization" 51 | 52 | Synchronization is a one-way process: the videos you add to the synchronized directory are sent to your api.video account. On the other hand: 53 | - if you delete a file from your synchronized folder, it won't be deleted from your api.video account, 54 | - if you add a file in your api.video account by another way, it won't be downloaded in your synchronized folder 55 | 56 | -------------------------------------------------------------------------------- /doc/activity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apivideo/api.video-desktop-synchronizer/3a6d0d4b7b5022031415cc266c7cbaa308b91da1/doc/activity.png -------------------------------------------------------------------------------- /doc/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apivideo/api.video-desktop-synchronizer/3a6d0d4b7b5022031415cc266c7cbaa308b91da1/doc/settings.png -------------------------------------------------------------------------------- /doc/start-synchronizing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apivideo/api.video-desktop-synchronizer/3a6d0d4b7b5022031415cc266c7cbaa308b91da1/doc/start-synchronizing.png -------------------------------------------------------------------------------- /entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.cs.allow-jit 6 | 7 | com.apple.security.cs.debugger 8 | 9 | 10 | -------------------------------------------------------------------------------- /forge.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const fs = require('fs'); 3 | const packageJson = require('./package.json'); 4 | 5 | const { version } = packageJson; 6 | const iconDir = path.resolve(__dirname, 'assets', 'icons'); 7 | 8 | if (process.env['WINDOWS_CODESIGN_FILE']) { 9 | const certPath = path.join(__dirname, 'win-certificate.pfx'); 10 | const certExists = fs.existsSync(certPath); 11 | 12 | if (certExists) { 13 | process.env['WINDOWS_CODESIGN_FILE'] = certPath; 14 | } 15 | } 16 | 17 | 18 | const config = { 19 | packagerConfig: { 20 | name: 'api-video', 21 | executableName: 'api-video', 22 | asar: true, 23 | icon: path.resolve(__dirname, 'src', 'assets', 'api-video-logo'), 24 | appBundleId: 'video.api.synchronizer', 25 | appCategoryType: 'public.app-category.video', 26 | win32metadata: { 27 | CompanyName: 'api.video', 28 | OriginalFilename: 'api-video', 29 | }, 30 | osxSign: { 31 | identity: 'Developer ID Application: Anthony Dantard (GBC36KP98K)', 32 | hardenedRuntime: true, 33 | 'gatekeeper-assess': false, 34 | entitlements: 'entitlements.plist', 35 | 'entitlements-inherit': 'entitlements.plist', 36 | 'signature-flags': 'library', 37 | }, 38 | }, 39 | makers: [ 40 | { 41 | name: '@electron-forge/maker-squirrel', 42 | platforms: ['win32'], 43 | config: (arch) => { 44 | return { 45 | name: 'api-video', 46 | authors: 'api.video', 47 | exe: 'api-video.exe', 48 | setupExe: `api-video-win32-${arch}-setup.exe`, 49 | setupIcon: path.resolve(__dirname, 'src', 'assets', 'api-video-logo.ico'), 50 | }; 51 | }, 52 | }, 53 | { 54 | name: '@electron-forge/maker-dmg', 55 | platforms: ['darwin'], 56 | config: { 57 | format: 'ULFO', 58 | name: 'api-video', 59 | icon: path.resolve(__dirname, 'src', 'assets', 'api-video-logo.icns'), 60 | } 61 | }, 62 | { 63 | name: '@electron-forge/maker-zip', 64 | platforms: ['darwin'] 65 | } 66 | ], 67 | publishers: [ 68 | { 69 | name: '@electron-forge/publisher-github', 70 | config: { 71 | repository: { 72 | owner: 'electron', 73 | name: 'fiddle', 74 | }, 75 | draft: true, 76 | prerelease: false, 77 | }, 78 | }, 79 | ], 80 | }; 81 | 82 | function notarizeMaybe() { 83 | if (process.platform !== 'darwin') { 84 | return; 85 | } 86 | 87 | if (!process.env.CI) { 88 | console.log(`Not in CI, skipping notarization`); 89 | return; 90 | } 91 | 92 | if (!process.env.APPLE_ID || !process.env.APPLE_ID_PASSWORD) { 93 | console.warn( 94 | 'Should be notarizing, but environment variables APPLE_ID or APPLE_ID_PASSWORD are missing!', 95 | ); 96 | return; 97 | } 98 | 99 | config.packagerConfig.osxNotarize = { 100 | appBundleId: 'video.api.synchronizer', 101 | appleId: process.env.APPLE_ID, 102 | appleIdPassword: process.env.APPLE_ID_PASSWORD 103 | }; 104 | } 105 | 106 | notarizeMaybe(); 107 | 108 | // Finally, export it 109 | module.exports = config; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "api-video-file-synchronizer", 3 | "productName": "api-video-file-synchronizer", 4 | "version": "0.1.2", 5 | "description": "My Electron application description", 6 | "main": "dist/index.js", 7 | "repository": { 8 | "type": "git", 9 | "url": "https://github.com/apivideo/api.video-desktop-synchronizer" 10 | }, 11 | "scripts": { 12 | "start": "tsc && electron-forge start", 13 | "package": "electron-forge package", 14 | "make": "tsc && cp -R src/assets dist && electron-forge make", 15 | "publish": "electron-forge publish", 16 | "lint": "eslint --ext .ts ." 17 | }, 18 | "keywords": [], 19 | "author": { 20 | "name": "Olivier Lando", 21 | "email": "olivier@api.video" 22 | }, 23 | "license": "MIT", 24 | "config": { 25 | "forge": "./forge.config.js" 26 | }, 27 | "devDependencies": { 28 | "@electron-forge/cli": "^6.0.0-beta.61", 29 | "@electron-forge/maker-deb": "^6.0.0-beta.61", 30 | "@electron-forge/maker-dmg": "^6.0.0-beta.61", 31 | "@electron-forge/maker-rpm": "^6.0.0-beta.61", 32 | "@electron-forge/maker-squirrel": "^6.0.0-beta.61", 33 | "@electron-forge/maker-zip": "^6.0.0-beta.61", 34 | "@types/electron-store": "^3.2.0", 35 | "@typescript-eslint/eslint-plugin": "^4.17.0", 36 | "@typescript-eslint/parser": "^4.17.0", 37 | "electron": "16.0.2", 38 | "eslint": "^7.6.0", 39 | "eslint-plugin-import": "^2.20.0", 40 | "typescript": "^4.0.2" 41 | }, 42 | "dependencies": { 43 | "@api.video/nodejs-client": "^2.0.14", 44 | "chokidar": "^3.5.2", 45 | "electron-notification-state": "^1.0.4", 46 | "electron-squirrel-startup": "^1.0.0", 47 | "electron-store": "^8.0.1", 48 | "node-fetch": "^3.1.0", 49 | "queue-promise": "^2.2.1", 50 | "update-electron-app": "^2.0.1" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/activity-client.ts: -------------------------------------------------------------------------------- 1 | import { UploadStatuses } from "./synchronizer"; 2 | 3 | const ipc = require('electron').ipcRenderer; 4 | 5 | 6 | const updateStatuses = (statuses: UploadStatuses) => { 7 | const statusesContainer = document.getElementById("logs"); 8 | statusesContainer.innerHTML = ""; 9 | for (const hash in statuses) { 10 | const status = statuses[hash]; 11 | const lineDiv = document.createElement("div"); 12 | const filenameDiv = document.createElement("div"); 13 | const dotsDiv = document.createElement("div"); 14 | dotsDiv.className = "dots"; 15 | const statusDiv = document.createElement("div"); 16 | lineDiv.className = "logline"; 17 | filenameDiv.innerHTML = status.filename; 18 | if (!status.link || status.status == "PROCESSING") { 19 | statusDiv.innerHTML = status.status === "IN_PROGRESS" ? Math.round(status.percent * 100) + "%" : status.status; 20 | } else { 21 | const link = document.createElement("button"); 22 | link.innerHTML = "VIEW"; 23 | link.onclick = () => ipc.send('open-in-browser', status.link); 24 | statusDiv.appendChild(link); 25 | } 26 | lineDiv.appendChild(filenameDiv); 27 | lineDiv.appendChild(dotsDiv); 28 | lineDiv.appendChild(statusDiv); 29 | statusesContainer.appendChild(lineDiv); 30 | } 31 | } 32 | 33 | 34 | window.addEventListener('DOMContentLoaded', () => { 35 | ipc.on('uploadStatuses', (event, arg) => { 36 | updateStatuses(arg); 37 | }) 38 | ipc.send('get-statuses'); 39 | }) -------------------------------------------------------------------------------- /src/activity-window.ts: -------------------------------------------------------------------------------- 1 | import { BrowserWindow, ipcMain, shell } from "electron"; 2 | import * as path from 'path'; 3 | import { UploadStatuses } from "./synchronizer"; 4 | 5 | 6 | export default class ActivityWindow { 7 | private browserWindow?: BrowserWindow; 8 | private uploadStatuses: UploadStatuses = {}; 9 | 10 | show() { 11 | if (!this.browserWindow) { 12 | this.browserWindow = this.createBrowserWindow(); 13 | this.browserWindow.setMenu(null); 14 | this.browserWindow.loadFile('dist/assets/activity.html'); 15 | this.browserWindow.on('close', () => this.onClose()); 16 | 17 | ipcMain.on('open-in-browser', (event, url) => shell.openExternal(url)); 18 | ipcMain.on('get-statuses', (event, arg) => event.reply('uploadStatuses', this.uploadStatuses)); 19 | } 20 | this.browserWindow.show(); 21 | } 22 | 23 | setUploadStatuses(uploadStatuses: UploadStatuses) { 24 | this.uploadStatuses = uploadStatuses; 25 | if(this.browserWindow) { 26 | this.browserWindow.webContents.send("uploadStatuses", uploadStatuses); 27 | } 28 | } 29 | 30 | private createBrowserWindow() { 31 | return new BrowserWindow({ 32 | width: 640, 33 | height: 380, 34 | webPreferences: { 35 | preload: path.join(__dirname, 'activity-client.js') 36 | } 37 | }); 38 | } 39 | 40 | private onClose() { 41 | this.browserWindow = undefined; 42 | ipcMain.removeAllListeners('get-statuses'); 43 | ipcMain.removeAllListeners('open-in-browser'); 44 | } 45 | } -------------------------------------------------------------------------------- /src/assets/Logo_white_text.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/assets/activity.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | api.video uploader 10 | 11 | 12 | 13 | 14 |
15 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/assets/api-video-logo.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apivideo/api.video-desktop-synchronizer/3a6d0d4b7b5022031415cc266c7cbaa308b91da1/src/assets/api-video-logo.icns -------------------------------------------------------------------------------- /src/assets/api-video-logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apivideo/api.video-desktop-synchronizer/3a6d0d4b7b5022031415cc266c7cbaa308b91da1/src/assets/api-video-logo.ico -------------------------------------------------------------------------------- /src/assets/green-dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apivideo/api.video-desktop-synchronizer/3a6d0d4b7b5022031415cc266c7cbaa308b91da1/src/assets/green-dot.png -------------------------------------------------------------------------------- /src/assets/orange-dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apivideo/api.video-desktop-synchronizer/3a6d0d4b7b5022031415cc266c7cbaa308b91da1/src/assets/orange-dot.png -------------------------------------------------------------------------------- /src/assets/settings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | api.video uploader 10 | 11 | 12 | 13 | 20 | 21 |
22 | 23 |
24 | 25 | 26 |
27 |
28 | 29 |
30 | 31 | 32 |
33 |
34 |
35 | 36 |
37 |
38 |
39 | 40 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/assets/styles.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #202124; 3 | color: #b8b1b6; 4 | font-family: arial; 5 | } 6 | 7 | #header { 8 | display: flex; 9 | justify-content: space-between; 10 | } 11 | 12 | #settings-button { 13 | font-size: 2em; 14 | color: white; 15 | padding: 0 10px; 16 | top: 0; 17 | height: fit-content; 18 | } 19 | 20 | #logo { 21 | display: flex; 22 | justify-content: space-evenly; 23 | margin-top: 2em; 24 | } 25 | 26 | .container { 27 | padding: 0 5em 0 5em; 28 | } 29 | 30 | #message { 31 | text-align: center; 32 | margin-top: 10px; 33 | color: #C00; 34 | font-size: 0.8em; 35 | } 36 | 37 | .field-section { 38 | display: flex; 39 | flex-direction: column; 40 | align-items: flex-start; 41 | margin: 2em 0; 42 | border-left: 5px solid #505154; 43 | padding-left: 1em; 44 | } 45 | 46 | #folder-field-line { 47 | display: flex; 48 | flex-direction: row; 49 | align-items: stretch; 50 | width: 100%; 51 | justify-content: space-between; 52 | } 53 | 54 | .dots { 55 | flex: 1; 56 | border-bottom: 1px dashed grey; 57 | bottom: 5px; 58 | position: relative; 59 | } 60 | 61 | .field-section.error { 62 | border-left: 5px solid #bb3333; 63 | } 64 | 65 | .field-section label { 66 | margin-bottom: 0.5em; 67 | } 68 | 69 | #folder { 70 | font-family: monospace; 71 | } 72 | 73 | #logs { 74 | background-color: #333; 75 | padding: 5px; 76 | margin-top: 1em; 77 | font-family: monospace; 78 | height: 100%; 79 | } 80 | 81 | #logs button { 82 | padding: 0; 83 | top: 0; 84 | font-family: monospace; 85 | font-weight: bold; 86 | cursor: pointer; 87 | } 88 | 89 | #logs .logline { 90 | display: flex; 91 | justify-content: space-between; 92 | flex-direction: row; 93 | padding: 2px; 94 | gap: 5px; 95 | } 96 | 97 | input { 98 | background-color: #202124; 99 | border: none; 100 | border-bottom: 1px solid #b8b1b6; 101 | padding: 0.5em; 102 | color: #b8b1b6; 103 | width: 100%; 104 | } 105 | 106 | button { 107 | background: none; 108 | border: none; 109 | color: #78a2f6; 110 | position: relative; 111 | top: -0.5em; 112 | padding: 0.5em 1em; 113 | border-radius: 3px; 114 | } 115 | 116 | button:hover { 117 | background-color: #303134; 118 | } 119 | 120 | input:focus { 121 | outline: none; 122 | background-color: #303134; 123 | } 124 | 125 | .container > .switch { 126 | display: block; 127 | margin: 12px auto; 128 | } 129 | 130 | .switch { 131 | position: relative; 132 | display: inline-block; 133 | vertical-align: top; 134 | width: 56px; 135 | height: 20px; 136 | padding: 0; 137 | background-color: white; 138 | border-radius: 18px; 139 | box-shadow: inset 0 -1px white, inset 0 1px 1px rgba(0, 0, 0, 0.05); 140 | cursor: pointer; 141 | background-image: -webkit-linear-gradient(top, #eeeeee, white 25px); 142 | background-image: -moz-linear-gradient(top, #eeeeee, white 25px); 143 | background-image: -o-linear-gradient(top, #eeeeee, white 25px); 144 | background-image: linear-gradient(to bottom, #eeeeee, white 25px); 145 | } 146 | 147 | .switch-input { 148 | position: absolute; 149 | top: 0; 150 | left: 0; 151 | opacity: 0; 152 | } 153 | 154 | .switch-label { 155 | position: relative; 156 | display: block; 157 | height: inherit; 158 | font-size: 10px; 159 | text-transform: uppercase; 160 | background: #eceeef; 161 | border-radius: inherit; 162 | box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12), inset 0 0 2px rgba(0, 0, 0, 0.15); 163 | -webkit-transition: 0.15s ease-out; 164 | -moz-transition: 0.15s ease-out; 165 | -o-transition: 0.15s ease-out; 166 | transition: 0.15s ease-out; 167 | -webkit-transition-property: opacity background; 168 | -moz-transition-property: opacity background; 169 | -o-transition-property: opacity background; 170 | transition-property: opacity background; 171 | } 172 | 173 | .switch-label:before, 174 | .switch-label:after { 175 | position: absolute; 176 | top: 50%; 177 | margin-top: -.5em; 178 | line-height: 1; 179 | -webkit-transition: inherit; 180 | -moz-transition: inherit; 181 | -o-transition: inherit; 182 | transition: inherit; 183 | } 184 | 185 | .switch-label:before { 186 | content: attr(data-off); 187 | right: 11px; 188 | color: #aaa; 189 | text-shadow: 0 1px rgba(255, 255, 255, 0.5); 190 | } 191 | 192 | .switch-label:after { 193 | content: attr(data-on); 194 | left: 11px; 195 | color: white; 196 | text-shadow: 0 1px rgba(0, 0, 0, 0.2); 197 | opacity: 0; 198 | } 199 | 200 | .switch-input:checked ~ .switch-label { 201 | background: #47a8d8; 202 | box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 0 3px rgba(0, 0, 0, 0.2); 203 | } 204 | 205 | .switch-input:checked ~ .switch-label:before { 206 | opacity: 0; 207 | } 208 | 209 | .switch-input:checked ~ .switch-label:after { 210 | opacity: 1; 211 | } 212 | 213 | .switch-handle { 214 | position: absolute; 215 | top: 1px; 216 | left: 1px; 217 | width: 18px; 218 | height: 18px; 219 | background: white; 220 | border-radius: 10px; 221 | box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2); 222 | background-image: -webkit-linear-gradient(top, white 40%, #f0f0f0); 223 | background-image: -moz-linear-gradient(top, white 40%, #f0f0f0); 224 | background-image: -o-linear-gradient(top, white 40%, #f0f0f0); 225 | background-image: linear-gradient(to bottom, white 40%, #f0f0f0); 226 | -webkit-transition: left 0.15s ease-out; 227 | -moz-transition: left 0.15s ease-out; 228 | -o-transition: left 0.15s ease-out; 229 | transition: left 0.15s ease-out; 230 | } 231 | 232 | .switch-handle:before { 233 | content: ''; 234 | position: absolute; 235 | top: 50%; 236 | left: 50%; 237 | margin: -6px 0 0 -6px; 238 | width: 12px; 239 | height: 12px; 240 | background: #f9f9f9; 241 | border-radius: 6px; 242 | box-shadow: inset 0 1px rgba(0, 0, 0, 0.02); 243 | background-image: -webkit-linear-gradient(top, #eeeeee, white); 244 | background-image: -moz-linear-gradient(top, #eeeeee, white); 245 | background-image: -o-linear-gradient(top, #eeeeee, white); 246 | background-image: linear-gradient(to bottom, #eeeeee, white); 247 | } 248 | 249 | .switch-input:checked ~ .switch-handle { 250 | left: 37px; 251 | box-shadow: -1px 1px 5px rgba(0, 0, 0, 0.2); 252 | } 253 | 254 | .switch-green > .switch-input:checked ~ .switch-label { 255 | background: #4fb845; 256 | } 257 | -------------------------------------------------------------------------------- /src/assets/tray-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apivideo/api.video-desktop-synchronizer/3a6d0d4b7b5022031415cc266c7cbaa308b91da1/src/assets/tray-icon.png -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { app, Menu, Tray } from 'electron'; 2 | import * as path from 'path'; 3 | import ActivityWindow from './activity-window'; 4 | import SettingsWindow from './settings-window'; 5 | import Synchronizer, { UploadStatuses } from './synchronizer'; 6 | 7 | 8 | let settingsWindow: SettingsWindow; 9 | let activityWindow: ActivityWindow; 10 | let synchronizer: Synchronizer; 11 | let tray: Tray; 12 | 13 | require('update-electron-app')(); 14 | 15 | // Handle creating/removing shortcuts on Windows when installing/uninstalling. 16 | if (require('electron-squirrel-startup')) { // eslint-disable-line global-require 17 | app.quit(); 18 | } 19 | 20 | 21 | const openSettingsWindow = (message?: string) => settingsWindow.show(message); 22 | const openActivityWindow = () => activityWindow.show(); 23 | 24 | const clickStart = () => synchronizer.start({ apiKey: settingsWindow.getSettings().apiKey, folder: settingsWindow.getSettings().folder }); 25 | const clickPause = () => synchronizer.stop().then((a) => tray.setContextMenu(contextMenuPaused)); 26 | 27 | const contextMenuPaused = Menu.buildFromTemplate([ 28 | { label: 'api.video synchronizer is paused', type: 'normal', enabled: false, icon: path.join(__dirname, 'assets/orange-dot.png') }, 29 | { label: 'Start synchronizing', type: 'normal', click: () => clickStart() }, 30 | { label: '', type: 'separator' }, 31 | { label: 'Activity...', type: 'normal', enabled: false }, 32 | { label: 'Settings...', type: 'normal', click: () => openSettingsWindow() }, 33 | { label: 'Quit', type: 'normal', click: () => app.quit() }, 34 | ]); 35 | 36 | const contextMenuActive = Menu.buildFromTemplate([ 37 | { label: 'api.video synchronizer is running', type: 'normal', enabled: false, icon: path.join(__dirname, 'assets/green-dot.png') }, 38 | { label: 'Pause', type: 'normal', click: () => clickPause() }, 39 | { label: '', type: 'separator' }, 40 | { label: 'Activity...', type: 'normal', click: () => openActivityWindow() }, 41 | { label: 'Settings...', type: 'normal', enabled: false }, 42 | { label: 'Quit', type: 'normal', click: () => app.quit() }, 43 | ]); 44 | 45 | 46 | const contextMenuBusy = Menu.buildFromTemplate([ 47 | { label: '...', type: 'normal', enabled: false }, 48 | { label: '', type: 'separator' }, 49 | { label: 'Activity...', type: 'normal', enabled: false }, 50 | { label: 'Settings...', type: 'normal', enabled: false }, 51 | { label: 'Quit', type: 'normal', click: () => app.quit() }, 52 | ]); 53 | 54 | const createTray = () => { 55 | const tray = new Tray(path.join(__dirname, 'assets/tray-icon.png')) 56 | tray.setToolTip('api.video synchronizer') 57 | tray.setContextMenu(contextMenuPaused); 58 | return tray; 59 | } 60 | 61 | 62 | app.on('ready', () => { 63 | if (app.dock) app.dock.hide(); 64 | tray = createTray(); 65 | 66 | settingsWindow = new SettingsWindow(); 67 | activityWindow = new ActivityWindow(); 68 | synchronizer = new Synchronizer(); 69 | 70 | if (!settingsWindow.getSettings().apiKey || !settingsWindow.getSettings().folder) { 71 | settingsWindow.show(); 72 | } 73 | 74 | synchronizer.on('auth-error', () => { 75 | settingsWindow.show("Please verify your API key"); 76 | clickPause(); 77 | }); 78 | 79 | synchronizer.on('upload-status-update', (statuses: UploadStatuses) => activityWindow.setUploadStatuses(statuses)); 80 | synchronizer.on('started', () => tray.setContextMenu(contextMenuActive)); 81 | synchronizer.on('stopped', () => tray.setContextMenu(contextMenuPaused)); 82 | synchronizer.on('busy', () => tray.setContextMenu(contextMenuPaused)); 83 | }); 84 | 85 | 86 | app.on('window-all-closed', () => { 87 | if (process.platform !== 'darwin') { 88 | // app.quit(); 89 | } 90 | }); 91 | -------------------------------------------------------------------------------- /src/settings-client.ts: -------------------------------------------------------------------------------- 1 | const ipc = require('electron').ipcRenderer; 2 | 3 | window.addEventListener('DOMContentLoaded', () => { 4 | 5 | const selectFolderButton = document.getElementById('select-folder-button'); 6 | const apiKeyInput = document.getElementById("apiKey") as HTMLInputElement; 7 | const folderText = document.getElementById("folder"); 8 | const applyButton = document.getElementById("apply-button"); 9 | const messageDiv = document.getElementById("message"); 10 | 11 | const params: any = {}; 12 | window.process.argv.forEach(t => { 13 | const match = t.match(/--([^=]+)=(.+)/); 14 | if(match) { 15 | params[match[1]] = match[2]; 16 | } 17 | }); 18 | 19 | const apiKey = params["apiKey"] || ""; 20 | const folder = params["folder"] || ""; 21 | 22 | apiKeyInput.value = apiKey; 23 | folderText.innerHTML = folder; 24 | 25 | 26 | selectFolderButton.addEventListener('click', (_) => ipc.send('open-file-dialog-for-file')); 27 | apiKeyInput.addEventListener('change', () => messageDiv.innerHTML = ""); 28 | 29 | 30 | applyButton.addEventListener('click', () => { 31 | ipc.send('update-settings', { 32 | folder: folderText.innerHTML, 33 | apiKey: apiKeyInput.value 34 | }) 35 | }); 36 | 37 | ipc.send('ready'); 38 | 39 | ipc.on('show-error-message', (_, message) => messageDiv.innerHTML = message); 40 | 41 | ipc.on('selected-file', (_, path) => { 42 | messageDiv.innerHTML = ""; 43 | if (!!path) { 44 | folderText.innerHTML = path; 45 | } 46 | }); 47 | 48 | 49 | ipc.on('update-status', (_, statuses) => { 50 | const statusesContainer = document.getElementById("logs"); 51 | statusesContainer.innerHTML = ""; 52 | for (const hash in statuses) { 53 | const status = statuses[hash]; 54 | const lineDiv = document.createElement("div"); 55 | const filenameDiv = document.createElement("div"); 56 | const statusDiv = document.createElement("div"); 57 | lineDiv.className = "logline"; 58 | filenameDiv.innerHTML = status.filename; 59 | if (!status.link) { 60 | statusDiv.innerHTML = status.status === "IN_PROGRESS" ? Math.round(status.percent * 100) + "%" : status.status; 61 | } else { 62 | const link = document.createElement("button"); 63 | link.innerHTML = "DONE"; 64 | link.onclick = () => ipc.send('open-in-browser', status.link); 65 | statusDiv.appendChild(link); 66 | } 67 | lineDiv.appendChild(filenameDiv); 68 | lineDiv.appendChild(statusDiv); 69 | statusesContainer.appendChild(lineDiv); 70 | } 71 | }); 72 | 73 | 74 | 75 | 76 | }) -------------------------------------------------------------------------------- /src/settings-window.ts: -------------------------------------------------------------------------------- 1 | import { BrowserWindow, dialog, ipcMain, IpcMainEvent, WebContents } from "electron"; 2 | import Store from 'electron-store'; 3 | import * as path from 'path'; 4 | import { isApiKeyValid } from "./tools"; 5 | 6 | export type Settings = { 7 | apiKey: string; 8 | folder: string; 9 | } 10 | 11 | export default class SettingsWindow { 12 | private store = new Store(); 13 | private message?: string; 14 | private browserWindow?: BrowserWindow; 15 | 16 | getSettings(): Settings { 17 | return { 18 | apiKey: this.store.get('apiKey') as string, 19 | folder: this.store.get('folder') as string, 20 | } 21 | } 22 | 23 | show(message?: string) { 24 | this.message = message; 25 | if (!this.browserWindow) { 26 | this.browserWindow = this.createBrowserWindow(); 27 | this.browserWindow.setMenu(null); 28 | this.browserWindow.loadFile('dist/assets/settings.html'); 29 | this.browserWindow.on('close', () => this.onClose()); 30 | 31 | ipcMain.on('ready', (e) => this.onReady(e)); 32 | ipcMain.on('update-settings', (event, settings) => this.onUpdateSettings(event, settings)); 33 | ipcMain.on('open-file-dialog-for-file', (event) => this.onOpenFileDialog(event)); 34 | } 35 | this.browserWindow.show(); 36 | } 37 | 38 | private onReady(event: IpcMainEvent) { 39 | if(this.message) { 40 | event.sender.send('show-error-message', this.message); 41 | } 42 | } 43 | 44 | private async onOpenFileDialog(event: IpcMainEvent) { 45 | dialog.showOpenDialog(this.browserWindow, { 46 | properties: ['openDirectory'] 47 | }).then((res) => { 48 | if (res) event.sender.send('selected-file', res.filePaths[0]); 49 | }); 50 | } 51 | 52 | private async onUpdateSettings(event: IpcMainEvent, settings: Settings) { 53 | if (!settings.folder && !settings.apiKey) { 54 | event.sender.send('show-error-message', "Please enter a valid API key and chose a folder to synchronize."); 55 | } else if (!settings.folder) { 56 | event.sender.send('show-error-message', "Please chose a folder to synchronize."); 57 | } else if (!settings.apiKey) { 58 | event.sender.send('show-error-message', "Please enter a valid API key."); 59 | } else if (!(await isApiKeyValid(settings.apiKey))) { 60 | event.sender.send('show-error-message', "Please enter a valid API key."); 61 | } else { 62 | this.store.set('apiKey', settings.apiKey); 63 | this.store.set('folder', settings.folder); 64 | this.browserWindow.close(); 65 | } 66 | } 67 | 68 | private createBrowserWindow() { 69 | return new BrowserWindow({ 70 | width: 640, 71 | height: 420, 72 | webPreferences: { 73 | preload: path.join(__dirname, 'settings-client.js'), 74 | additionalArguments: ["--apiKey="+(this.getSettings().apiKey || ""), "--folder=" + (this.getSettings().folder || "")] 75 | } 76 | }) 77 | } 78 | 79 | private onClose() { 80 | this.browserWindow = undefined; 81 | ipcMain.removeAllListeners('open-file-dialog-for-file'); 82 | ipcMain.removeAllListeners('update-settings'); 83 | } 84 | } -------------------------------------------------------------------------------- /src/synchronizer.ts: -------------------------------------------------------------------------------- 1 | import ApiVideoClient from "@api.video/nodejs-client"; 2 | import { FSWatcher, watch } from "chokidar"; 3 | import { createHash } from 'crypto'; 4 | import { clipboard, shell } from "electron"; 5 | import { Notification } from "electron/main"; 6 | import { EventEmitter } from 'events'; 7 | import { createReadStream } from 'fs'; 8 | import { Stats } from "original-fs"; 9 | import path from 'path'; 10 | import Queue from "queue-promise"; 11 | import { Settings } from "./settings-window"; 12 | import { isApiKeyValid } from "./tools"; 13 | 14 | type UploadStatus = { 15 | status: "PENDING" | "DONE" | "IN_PROGRESS" | "PROCESSING"; 16 | percent?: number; 17 | filename?: string; 18 | link?: string; 19 | }; 20 | 21 | export type UploadStatuses = Record 22 | 23 | export default class Synchronizer extends EventEmitter { 24 | private settings?: Settings; 25 | private watcher?: FSWatcher; 26 | private uploadStatuses: UploadStatuses = {}; 27 | private uploadQueue: Queue; 28 | 29 | constructor() { 30 | super(); 31 | } 32 | 33 | async start(settings: Settings) { 34 | this.emit("busy"); 35 | this.uploadStatuses = {}; 36 | this.settings = settings; 37 | 38 | if (this.watcher) { 39 | await this.watcher.close(); 40 | this.watcher = undefined; 41 | } 42 | 43 | if (!await isApiKeyValid(settings.apiKey)) { 44 | this.emit("auth-error"); 45 | this.stop(); 46 | return; 47 | } 48 | 49 | 50 | this.uploadQueue = new Queue({ 51 | concurrent: 1, 52 | interval: 100 53 | }); 54 | 55 | this.watcher = watch(settings.folder, { awaitWriteFinish: true }) 56 | .on('add', async (path, fileStat) => this.onNewFile(path, fileStat)); 57 | 58 | this.emit("started"); 59 | 60 | } 61 | 62 | private updateUploadStatus(hash: string, status: UploadStatus) { 63 | this.uploadStatuses[hash] = { 64 | ...(this.uploadStatuses[hash] ? this.uploadStatuses[hash] : {}), 65 | ...status 66 | }; 67 | this.emit('upload-status-update', this.uploadStatuses); 68 | } 69 | 70 | private async onNewFile(filePath: string, stats?: Stats) { 71 | if ([".mp4", ".mov"].indexOf(path.extname(filePath).toLowerCase()) === -1) { 72 | return; 73 | } 74 | 75 | const hash = await this.computeFileHash(filePath); 76 | 77 | if (!!this.uploadStatuses[hash]) { 78 | return; 79 | } 80 | 81 | const filename = filePath.substr(this.settings.folder.length + 1); 82 | 83 | this.updateUploadStatus(hash, { status: 'PENDING', percent: 0, filename }); 84 | 85 | const apiVideoClient = new ApiVideoClient({ apiKey: this.settings.apiKey }); 86 | 87 | try { 88 | const existingVideo = await apiVideoClient.videos.list({ metadata: { uploaderhash: hash } }); 89 | 90 | if (existingVideo.pagination.itemsTotal === 0) { 91 | this.updateUploadStatus(hash, { status: 'PENDING', percent: 0, filename }); 92 | this.uploadQueue.enqueue(() => this.uploadFile(filePath, hash, apiVideoClient)); 93 | } else { 94 | const uploadedChunksMetadata = existingVideo.data[0].metadata.find(m => m.key === 'uploaderuploadstatus' && m.value === "done"); 95 | if (!uploadedChunksMetadata) { 96 | await apiVideoClient.videos.delete(existingVideo.data[0].videoId); 97 | this.uploadQueue.enqueue(() => this.uploadFile(filePath, hash, apiVideoClient)); 98 | } else { 99 | this.updateUploadStatus(hash, { status: 'DONE', percent: 100, filename, link: existingVideo.data[0].assets.player }); 100 | } 101 | } 102 | } catch (e) { 103 | if (e.problemDetails.status == 401) { 104 | this.emit("auth-error"); 105 | this.stop(); 106 | } 107 | } 108 | } 109 | 110 | async stop() { 111 | this.emit("busy"); 112 | if (this.watcher) { 113 | await this.watcher.close(); 114 | this.watcher = undefined; 115 | } 116 | this.emit("stopped"); 117 | } 118 | 119 | private async uploadFile(filePath: string, hash: string, apiVideoClient: ApiVideoClient) { 120 | this.updateUploadStatus(hash, { status: "IN_PROGRESS" }); 121 | 122 | const creationResult = await apiVideoClient.videos.create({ 123 | title: path.basename(filePath), 124 | metadata: [{ key: "uploaderhash", value: hash }] 125 | }); 126 | 127 | const uploadResult = await apiVideoClient.videos.upload( 128 | creationResult.videoId, 129 | filePath, 130 | (progress) => this.updateUploadStatus(hash, { status: "IN_PROGRESS", percent: progress.uploadedBytes / progress.totalBytes }) 131 | ); 132 | 133 | await apiVideoClient.videos.update(creationResult.videoId, { 134 | metadata: [ 135 | { key: "uploaderhash", value: hash }, 136 | { key: "uploaderuploadstatus", value: "done" } 137 | ] 138 | }); 139 | 140 | this.updateUploadStatus(hash, { link: uploadResult.assets.player, status: "PROCESSING", percent: 100 }); 141 | 142 | let statusInterval = setInterval(() => { 143 | apiVideoClient.videos.getStatus(uploadResult.videoId).then((s) => { 144 | if (s.encoding.playable) { 145 | this.showNotification(uploadResult.title, uploadResult.assets.player); 146 | this.updateUploadStatus(hash, { status: "DONE" }); 147 | clearInterval(statusInterval); 148 | } 149 | }) 150 | }, 2000); 151 | 152 | } 153 | 154 | private async computeFileHash(path: string): Promise { 155 | return await new Promise((resolve, reject) => { 156 | const hash = createHash('md5'); 157 | const stream = createReadStream(path); 158 | stream.on('data', (data: string) => hash.update(data, 'utf8')); 159 | stream.on('end', () => resolve(hash.digest('hex'))); 160 | }); 161 | } 162 | 163 | private showNotification(videoTitle: string, videoUrl: string) { 164 | const notif = new Notification({ 165 | title: 'Video uploaded', 166 | body: `Your video "${videoTitle}" has been uploaded. Click to open it.`, 167 | icon: 'assets/tray-icon.png', 168 | actions: [{ 169 | text: "Copy url", 170 | type: "button" 171 | }] 172 | }); 173 | notif.on("click", () => shell.openExternal(videoUrl)); 174 | notif.on("action", (e) => clipboard.writeText(videoUrl)); 175 | notif.show(); 176 | } 177 | } -------------------------------------------------------------------------------- /src/tools.ts: -------------------------------------------------------------------------------- 1 | import ApiVideoClient from "@api.video/nodejs-client"; 2 | 3 | export const isApiKeyValid = async (apiKey: string): Promise => { 4 | try { 5 | await new ApiVideoClient({apiKey}).getAccessToken(); 6 | return true; 7 | } catch(e) { 8 | return false; 9 | } 10 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "allowJs": true, 4 | "module": "commonjs", 5 | "target": "ES2015", 6 | "noImplicitAny": true, 7 | "sourceMap": true, 8 | "baseUrl": ".", 9 | "outDir": "dist", 10 | "moduleResolution": "node", 11 | "resolveJsonModule": true, 12 | "esModuleInterop": true 13 | }, 14 | "include": [ 15 | "src/**/*" 16 | ] 17 | } 18 | --------------------------------------------------------------------------------