Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
Rewrite to adjust for new Webpage
Browse files Browse the repository at this point in the history
- [x] fix requests

- [x] update exaple responses

- [x] update typings

- [x] update documentation / README

- [x] rewrite tests

closes #72 
closes #83 
closes #84 
closes #100 

# Porting code
* request options for miniget were moved to `options#requestOptions`
* nextpageRef was replaced by the continuation feature => check the README for more information
*  `pages` was added as a more request-efficient alternative to `limit`
* `playlist#visibility#link_only` was renamed to `unlisted`
* all thumbnails are now Objects of type `Image` featuring `url`, `width` and `height` properties - arrays of images are always sorted by descending resolution
* all links have been renamed from `ref` to `url` to keep it consistend across all libraries
* all snake_case variables were replaced by CamelCase
* `response#result_items` is now `response#estimatedItemCount`
* all users/channels feature both the `channelID` as well as a canonical `url`
  • Loading branch information
TimeForANinja authored Dec 13, 2020
2 parents 2311c74 + caf1fc1 commit eabca3c
Show file tree
Hide file tree
Showing 57 changed files with 25,051 additions and 10,920 deletions.
37 changes: 17 additions & 20 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,43 @@
},
"env": {
"es6": true,
"node": true
"node": true,
"mocha": false
},
"rules": {
"no-await-in-loop": "warn",
"no-await-in-loop": "off",
"no-compare-neg-zero": "error",
"no-extra-parens": ["warn", "all", {
"nestedBinaryExpressions": false
}],
"no-template-curly-in-string": "error",
"no-unsafe-negation": "error",
"valid-jsdoc": ["error", {
"requireReturn": false,
"requireReturnDescription": false,
"valid-jsdoc": ["warn", {
"prefer": {
"return": "returns",
"arg": "param"
"arg": "param",
"return": "returns"
},
"preferType": {
"String": "string",
"Number": "number",
"Boolean": "boolean",
"Symbol": "symbol",
"Number": "number",
"object": "Object",
"function": "Function",
"array": "Array",
"date": "Date",
"error": "Error",
"null": "void"
}
"String": "string"
},
"requireReturn": false,
"requireReturnType": true,
"requireParamDescription": false,
"requireReturnDescription": false,
"requireParamType": true
}],

"no-prototype-builtins" : "off",
"accessor-pairs": "warn",
"array-callback-return": "error",
"complexity": "warn",
"complexity": ["off", { "max": 25 }],
"consistent-return": "warn",
"curly": ["error", "multi-line", "consistent"],
"dot-location": ["error", "property"],
"dot-notation": "error",
"eqeqeq": "error",
"no-console": ["error", { "allow": ["warn"] }],
"no-empty-function": "error",
"no-floating-decimal": "error",
"no-implied-eval": "error",
Expand All @@ -55,7 +52,7 @@
"no-new-wrappers": "error",
"no-new": "error",
"no-octal-escape": "error",
"no-return-assign": "error",
"no-return-assign": "off",
"no-return-await": "error",
"no-self-compare": "error",
"no-sequences": "error",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

- uses: actions/setup-node@v1
with:
node-version: 13.x
node-version: 14.x

- name: npm install, build, and lint
run: |
Expand Down
22 changes: 19 additions & 3 deletions .github/workflows/node_ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: Node.js CI

on: [push]
on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
node-version: [10.x, 12.x, 14.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -24,3 +23,20 @@ jobs:
- run: npm test
env:
CI: true

codecov:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x

- run: npm install
- run: npm run build --if-present
- run: npm run-script test:coverage
env:
CI: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
coverage
.nyc_output
dumps
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
[![Known Vulnerabilities](https://snyk.io/test/github/timeforaninja/node-ytpl/badge.svg)](https://snyk.io/test/github/timeforaninja/node-ytpl)
[![Discord](https://img.shields.io/discord/484464227067887645.svg)](https://discord.gg/V3vSCs7)

[![NPM info](https://nodei.co/npm/ytpl.png?downloads=true&stars=true)](https://nodei.co/npm/ytpl/)

Simple js only module to resolve YouTube playlist ids
Doesn't need any login or GoogleAPI key

Expand All @@ -18,11 +16,8 @@ You can contact us for support on our [chat server](https://discord.gg/V3vSCs7)
```js
var ytpl = require('ytpl');

ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg').then(playlist => {
dosth(playlist);
}).catch(err => {
console.error(err);
});
const playlist = await ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg');
dosth(playlist);
```


Expand All @@ -34,16 +29,35 @@ Attempts to resolve the given playlist id
* `id`
* id of the yt-playlist
* or playlist link
* or user link (resolves uploaded playlist)
* or channel link (resolves uploaded playlist)
* or user link (resolves to uploaded playlist)
* or channel link (resolves to uploaded playlist)
* `options`
* object with options
* possible settings:
* gl[String] -> 2-Digit Code of a Country, defaults to `US` - Allows for localisation of the request
* hl[String] -> 2-Digit Code for a Language, defaults to `en` - Allows for localisation of the request
* limit[Number] -> limits the pulled items, defaults to 100, set to Infinity to get the whole playlist - numbers <1 result in the default being used
* All additional parameters will get passed to [miniget](https://github.com/fent/node-miniget), which is used to do the https requests
* pages[Number] -> limits the pulled pages, pages contain 100 items, set to Infinity to get the whole playlist - numbers <1 result in the default limit being used - overwrites limit
* requestOptions[Object] -> Additional parameters to passed to [miniget](https://github.com/fent/node-miniget), which is used to do the https requests

* returns a Promise
* [Example response](https://github.com/timeforaninja/node-ytpl/blob/master/example/example_output)
* [Example response](https://github.com/timeforaninja/node-ytpl/blob/master/example/example_output.txt)

### ytpl.continueReq(continuationData)
Continues a previous request by pulling yet another page.
The previous request had to be done using `pages` limitation.

#### Usage
```js
var ytpl = require('ytpl');

const playlist = await ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg', { pages: 1 });
display(playlist.items);
const r2 = ytpl.continueReq(playlist.continuation);
display(r2.items);
const r3 = ytpl.continueReq(r2.continuation);
display(r3.items);
```

### ytpl.validateID(string)

Expand All @@ -67,6 +81,5 @@ Returns a promise.
npm install --save ytpl



# License
MIT
188 changes: 0 additions & 188 deletions example/example_output

This file was deleted.

Loading

0 comments on commit eabca3c

Please sign in to comment.