Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
GoneTone committed Sep 7, 2021
0 parents commit b138e53
Show file tree
Hide file tree
Showing 12 changed files with 10,790 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
env: {
commonjs: true,
es2021: true,
node: true,
jest: true
},
extends: [
'standard'
],
parserOptions: {
ecmaVersion: 12
},
rules: {
}
}
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username

custom: ['https://donate.reh.tw/', 'https://paypal.me/GoneTone']
35 changes: 35 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CD

on:
release:
types: [ published ]

jobs:
test:
runs-on: ${{ matrix.operating-system }}

strategy:
fail-fast: false

matrix:
operating-system: [ ubuntu-latest ]
node-version: [ 16.x ]

name: NPM Publish
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'

- name: Install Dependencies
run: npm install

- name: Publish
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on: [push, pull_request]

jobs:
test:
runs-on: ${{ matrix.operating-system }}

strategy:
fail-fast: false

matrix:
operating-system: [ ubuntu-latest ]
node-version: [ 12.x, 14.x, 15.x, 16.x ]

name: Node.js ${{ matrix.node-version }} Test on ${{ matrix.operating-system }}
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: Install Dependencies
run: npm ci

- name: Run ESLint
run: npm run lint

- name: Jest Tests
run: npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/.idea/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (C) 2021 by GoneTone

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Get YouTube ID By Url (Node.js Library)

Get YouTube channel or video id by url!

## Report Issues

Please report any bugs you discover at <https://github.com/GoneToneStudio/node-get-youtube-id-by-url/issues>

## Installation

Node.js 12.0.0 or newer is required.

### With NPM

```sh-session
npm install @gonetone/get-youtube-id-by-url
```

## Examples

```javascript
const { channelId, videoId } = require('@gonetone/get-youtube-id-by-url')
```

### Get YouTube Channel ID By Url

```javascript
channelId('YouTube Channel Url').then((id) => {
console.log(id)
})
```

Support URL format:

- https://www.youtube.com/channel/xxxxxxxxxxxxxxxxxxxxxxxx
- https://www.youtube.com/c/xxxxxxxx
- https://www.youtube.com/user/xxxxxxxx

### Get YouTube Video ID By Url

```javascript
videoId('YouTube Video Url').then((id) => {
console.log(id)
})
```

Support URL format:

- https://www.youtube.com/watch?v=xxxxxxxxxxx
- https://youtu.be/xxxxxxxxxxx

## License

[MIT](LICENSE)
37 changes: 37 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2014-2021 旋風之音 GoneTone
*
* Website: https://blog.reh.tw/
* GitHub: https://github.com/GoneTone
* Facebook: https://www.facebook.com/GoneToneDY
* Twitter: https://twitter.com/TPGoneTone
*
* Project GitHub: https://github.com/GoneToneStudio/node-get-youtube-id-by-url
*
* _oo0oo_
* o8888888o
* 88" . "88
* (| -_- |)
* 0\ = /0
* ___/`---'\___
* .' \\| |# '.
* / \\||| : |||# \
* / _||||| -:- |||||- \
* | | \\\ - #/ | |
* | \_| ''\---/'' |_/ |
* \ .-\__ '-' ___/-. /
* ___'. .' /--.--\ `. .'___
* ."" '< `.___\_<|>_/___.' >' "".
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
* \ \ `_. \_ __\ /__ _/ .-` / /
* =====`-.____`.___ \_____/___.-`___.-'=====
* `=---='
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* 佛祖保佑 永無 BUG
*/

'use strict'

const GetYouTubeIdByUrl = require('./src/GetYouTubeIdByUrl')

module.exports = GetYouTubeIdByUrl
Loading

0 comments on commit b138e53

Please sign in to comment.