Skip to content

Commit

Permalink
Merged #6: v0.6.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
itsrn authored Aug 22, 2023
2 parents c16f4e8 + 138fb79 commit bf65787
Show file tree
Hide file tree
Showing 18 changed files with 1,179 additions and 92 deletions.
16 changes: 11 additions & 5 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ body:
description: |
Steps to reproduce the behavior:
value: |
1. Install the package
2. Use '...'
3. Get error
1.
2.
3.
validations:
required: true
- type: 'input'
Expand All @@ -33,8 +33,14 @@ body:
id: 'lib-version'
attributes:
label: 'Hidabroot API Version'
description: 'The version of library you use.'
placeholder: '0.5.0'
description: 'The version of the package you used (you can run `npm list hidabroot` to find it).'
validations:
required: true
- type: 'input'
id: 'lib-version'
attributes:
label: 'Puppeteer Version'
description: 'The version of puppeteer you are using (you can run `npm list puppeteer` to find it).'
validations:
required: true
- type: 'checkboxes'
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Publish

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [created]

jobs:
publish:
runs-on: ubuntu-latest
Expand Down
33 changes: 30 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
_An (unofficial) API for Hidabroot_

## Important

This API may be blocked at any time by Hidabroot's team. If any damage caused by this API, it is not my fault, use this API at your own risk.

## Install
Expand All @@ -25,25 +26,51 @@ yarn add hidabroot
## Features

#### Note

The current version is still in beta, meaning more features are coming soon and still in development.

- [Getting the news titles from the website](#todaynews)
- [Viewing articles contents](#getarticle)

## API

### todayNews

Returns a promise that resolves to an array of 4 strings (if there is an error it will return null instead) of the top "Hadshot Hayom" from Hidabroot's website.
Returns a promise that resolves to a JSON of 5 keys. Each key is the article title, and each key's value is the ID of the article (if there is an error or an issue with getting the values, it will return an empty string as the article title and 0 as the ID) of the top "Hadshot Hayom" from Hidabroot's website. The first key is the biggest box at the top of the page, while the other 4 are the smaller under it.

#### Example:

```js
const Hidabroot = require("hidabroot");
Hidabroot.todayNews().then((result) => {
const { todayNews } = require("hidabroot");
todayNews().then((result) => {
console.log(result);
});
```

### getArticle

Returns a promise that resolves to a string (or null, if the article was not found). Here is a detailed table of the parameters of the function:

| Field | Type | Description | Required |
| ----- | ------ | ------------------------------------------------------------------------------------------ | -------- |
| id | number | The ID of the article. Can be found in `https://www.hidabroot.org/article/X` (X is the ID) | yes |

#### Example:

```js
const { todayNews, getArticle } = require("hidabroot");
todayNews().then((article) => {
//gets todays news
const desiredKey = Object.keys(article)[0];
//gets the first key in the json. the first article is the biggest box at the top
getArticle(article[desiredKey]).then((articleContent) => {
//gets the article content of the biggest box at the top
console.log(articleContent);
//returns the content to the console
});
});
```

## Contributing

All contributions are welcome! Feel free to open an issue or a pull request.
6 changes: 6 additions & 0 deletions build/getArticle/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Get any article content by it's ID.
*
* @param {number} id The id of the article
*/
export declare function getArticle(id: number): Promise<string | null>;
85 changes: 85 additions & 0 deletions build/getArticle/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build/getArticle/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions build/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import { todayNews } from "./todayNews/index";
export { todayNews };
import { todayNews } from "./todayNews";
import { getArticle } from "./getArticle";
export { todayNews, getArticle };
8 changes: 5 additions & 3 deletions build/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions build/todayNews/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Retrieves the news titles from "Hadshot Hayom" and returns them in a JSON format.
*
* @returns {Promise<string[] | null>} An array of news titles extracted from the website or null if an error occurs.
* @returns {Promise<{ [key: string]: number }>} An array of news titles extracted from the website or null if an error occurs.
*/
export declare function todayNews(): Promise<string[] | null>;
export declare function todayNews(): Promise<{
[key: string]: number;
}>;
117 changes: 77 additions & 40 deletions build/todayNews/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bf65787

Please sign in to comment.