diff --git a/.github/workflows/pr_agent.yml b/.github/workflows/pr_agent.yml new file mode 100644 index 0000000..a39fbb9 --- /dev/null +++ b/.github/workflows/pr_agent.yml @@ -0,0 +1,18 @@ +on: + pull_request: + issue_comment: + jobs: + pr_agent_job: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + contents: write + name: Run pr agent on every pull request, respond to user comments + steps: + - name: PR Agent action step + id: pragent + uses: Codium-ai/pr-agent@main + env: + OPENAI_KEY: ${{ secrets.OPENAI_KEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index e1f46d8..0bb1d99 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ ![GitHub Stars](https://img.shields.io/github/stars/SxMAbel/media_hosting_api.svg) [![Issues](https://img.shields.io/github/issues/SxMAbel/media_hosting_api.svg)](https://github.com/SxMAbel/media_hosting_api/issues) [![Pull Requests](https://img.shields.io/github/issues-pr/SxMAbel/media_hosting_api.svg)](https://github.com/SxMAbel/media_hosting_api/pulls) +![GitHub Latest Pre-Release)](https://img.shields.io/github/v/release/SxMAbel/media_hosting_api?include_prereleases&label=pre-release&logo=github) +![GitHub Latest Release)](https://img.shields.io/github/v/release/SxMAbel/media_hosting_api?logo=github) **Media Hosting API** is an open-source solution for streaming and managing media files. It provides a simple and efficient way to upload, access, and delete various types of media files. With Media Hosting API, you can streamline your media hosting needs and easily integrate media file management into your applications. diff --git a/pages/howto.html b/pages/howto.html deleted file mode 100644 index 7e0261b..0000000 --- a/pages/howto.html +++ /dev/null @@ -1,245 +0,0 @@ - - - -
- - -/api/v1/check/:id
- Check if a media file exists by ID. Returns 'isFound', 'id', 'url'.
- /api/v1/delete/:id
- Remove a file by ID. Returns 'deleted', 'message'.
- /api/v1/play/:id
- Stream only videos or mp3 files. Turns link into stream source.
- /api/v1/upload
- Upload either images, video files, audio files. Returns 'id', 'url'.
- /api/v1/view/:id
- Get source link of the media that includes the ID. Returns 'url'.
-
- if any error is encountered to access the error, use response.data.error
-
- If any bugs found and you fixed them please create a pull - request, much appreciated. <3 -
- - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pages/index.html b/pages/index.html new file mode 100644 index 0000000..e69de29 diff --git a/pages/scripts/darkmode.js b/pages/scripts/darkmode.js new file mode 100644 index 0000000..2a21162 --- /dev/null +++ b/pages/scripts/darkmode.js @@ -0,0 +1,14 @@ +const darkModeToggle = document.getElementById('dark-mode-toggle'); + const toggleSlider = document.querySelector('.toggle-slider'); + + darkModeToggle.addEventListener('change', function () { + if (this.checked) { + document.body.classList.add('dark-mode'); + toggleSlider.classList.remove('sun-mode'); + toggleSlider.classList.add('moon-mode'); + } else { + document.body.classList.remove('dark-mode'); + toggleSlider.classList.remove('moon-mode'); + toggleSlider.classList.add('sun-mode'); + } + }); diff --git a/pages/styles/styles.css b/pages/styles/styles.css new file mode 100644 index 0000000..c0b38d2 --- /dev/null +++ b/pages/styles/styles.css @@ -0,0 +1,121 @@ +body { + font-family: Arial, sans-serif; + margin: 20px; + } + + h2 { + color: #333; + border-bottom: 1px solid #ccc; + } + + ul { + list-style-type: none; + padding: 0; + } + + li { + margin-bottom: 10px; + } + + code { + background-color: #f0f0f0; + padding: 2px 4px; + border-radius: 4px; + } + + p { + margin-top: 10px; + } + + /* Dark mode styles */ + body.dark-mode { + background-color: #333; + color: #f0f0f0; + } + + body.dark-mode h2 { + color: #f0f0f0; + border-bottom-color: #999; + } + + body.dark-mode ul { + color: #f0f0f0; + } + + body.dark-mode code { + background-color: #555; + color: #f0f0f0; + } + + body.dark-mode #gitlink { + color: lightskyblue; + } + + /* Light mode styles */ + body.light-mode { + background-color: #f0f0f0; + color: #333; + } + + body.light-mode h2 { + color: #333; + border-bottom-color: #ccc; + } + + body.light-mode ul { + color: #333; + } + + body.light-mode code { + background-color: #f0f0f0; + color: #333; + } + + /* Fancy button styles */ + .fancy-button { + background-color: #007bff; + color: #fff; + border: none; + padding: 10px 20px; + font-size: 16px; + border-radius: 4px; + cursor: pointer; + transition: background-color 0.3s ease; + } + + .fancy-button:hover { + background-color: #0056b3; + } + + /* Dark Mode Toggle Switch Styles */ + .button-container { + position: absolute; + top: 10px; + right: 10px; + } + + .toggle-switch { + position: relative; + display: inline-block; + width: 60px; + height: 34px; + } + + /* ... (rest of the styles for the Dark Mode Toggle Switch) ... */ + + /* Navigation Arrows Styles */ + .navigation-arrows { + margin-top: 20px; + } + + .navigation-arrows a { + margin-right: 10px; + text-decoration: none; + color: #007bff; + font-weight: bold; + } + + .navigation-arrows a:hover { + color: #0056b3; + } + \ No newline at end of file diff --git a/pages/web.md b/pages/web.md new file mode 100644 index 0000000..abf9c3d --- /dev/null +++ b/pages/web.md @@ -0,0 +1,262 @@ +[![License](https://img.shields.io/badge/license-Apache-blue.svg)](https://github.com/SxMAbel/media_hosting_api/blob/main/LICENSE) +[![Contributions Welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg)](https://github.com/SxMAbel/media_hosting_api/pulls) +![GitHub Stars](https://img.shields.io/github/stars/SxMAbel/media_hosting_api.svg) +[![Issues](https://img.shields.io/github/issues/SxMAbel/media_hosting_api.svg)](https://github.com/SxMAbel/media_hosting_api/issues) +[![Pull Requests](https://img.shields.io/github/issues-pr/SxMAbel/media_hosting_api.svg)](https://github.com/SxMAbel/media_hosting_api/pulls) +![GitHub Latest Pre-Release)](https://img.shields.io/github/v/release/SxMAbel/media_hosting_api?include_prereleases&label=pre-release&logo=github) +![GitHub Latest Release)](https://img.shields.io/github/v/release/SxMAbel/media_hosting_api?logo=github) +# Media Hosting API Documentation + +## Introduction + +Welcome to the documentation for the Media Hosting API npm package, an open-source solution designed to streamline media file hosting and management. This npm package provides a straightforward and efficient way to handle various types of media files, allowing you to seamlessly integrate media file management into your Node.js applications. + +--- + +## Installation + +To use the Media Hosting API npm package, you need to install it using npm. Run the following command in your terminal: + +```bash +npm install media-hosting-api +``` + +--- + +## Usage + +Once installed, you can use the Media Hosting API in your Node.js application by requiring it: + +```javascript +const mediaHostingApi = require('media-hosting-api'); +``` + +--- + +## Check Media File Existence + +**Endpoint:** `GET /api/v1/check/:id` + +Check if a media file exists by providing its ID. + +### Example + +```javascript +const result = mediaHostingApi.checkMediaFileExistence('123456'); +console.log(result); +``` + +Output: + +```json +{ + "isFound": true, + "id": "123456", + "url": "https://example.com/media/123456" +} +``` + +--- + +## Delete Media File + +**Endpoint:** `DELETE /api/v1/delete/:id` + +Remove a media file by providing its ID. + +### Example + +```javascript +const result = mediaHostingApi.deleteMediaFile('123456'); +console.log(result); +``` + +Output: + +```json +{ + "deleted": true, + "message": "Media file with ID 123456 deleted successfully." +} +``` + +--- + +## Stream Media (Videos or MP3) + +**Endpoint:** `GET /api/v1/play/:id` + +Stream videos or MP3 files by providing the media file ID. This endpoint transforms the link into a stream source for seamless playback. + +### Example + +```javascript +const result = mediaHostingApi.streamMedia('123456'); +console.log(result); +``` + +Output: + +```json +{ + "streaming_url": "https://example.com/stream/123456" +} +``` + +--- + +## Upload Media File + +**Endpoint:** `POST /api/v1/upload` + +Upload media files, including images, video files, and audio files. + +### Example + +```javascript +const result = mediaHostingApi.uploadMediaFile('/path/to/file.jpg'); +console.log(result); +``` + +Output: + +```json +{ + "id": "789012", + "url": "https://example.com/media/789012" +} +``` + +--- + +## View Media Source Link + +**Endpoint:** `GET /api/v1/view/:id` + +Retrieve the source link of the media file by providing its ID. + +### Example + +```javascript +const result = mediaHostingApi.viewMediaSourceLink('789012'); +console.log(result); +``` + +Output: + +```json +{ + "url": "https://example.com/source/789012" +} +``` + +--- + +## Accessing Errors + +If you encounter any errors while using the API, you can access the specific error message by checking the error property in the response. + +### Example + +```javascript +try { + const result = mediaHostingApi.checkMediaFileExistence('nonexistent'); + console.log(result); +} catch (error) { + console.error(error.message); +} +``` + +Output: + +```json +{ + "error": "Media file not found." +} +``` + +Feel free to explore and integrate these functions into your Node.js applications for efficient media file hosting and management using the Media Hosting API npm package! + +## Customization and Configuration + +The Media Hosting API npm package provides options for customization and configuration. You can set the API endpoint, authentication tokens, and other parameters to tailor the package to your specific requirements. + +### Example + +```javascript +const mediaHostingApi = require('media-hosting-api'); + +// Set API endpoint (optional, default is 'https://api.mediahosting.com') +mediaHostingApi.setEndpoint('https://custom-api-endpoint.com'); + +// Set authentication token (optional, if required by your Media Hosting API setup) +mediaHostingApi.setAuthToken('your-authentication-token'); + +// Use the configured API instance for subsequent calls +const result = mediaHostingApi.checkMediaFileExistence('123456'); +console.log(result); +``` + +--- + +## Handling Rate Limits + +Media Hosting API may have rate limits to prevent abuse. It's crucial to handle rate-limiting scenarios gracefully in your application. The npm package includes mechanisms to detect rate limits and manage requests accordingly. + +### Example + +```javascript +const mediaHostingApi = require('media-hosting-api'); + +try { + const result = mediaHostingApi.checkMediaFileExistence('123456'); + console.log(result); +} catch (error) { + if (error.statusCode === 429) { + console.error('Rate limit exceeded. Please wait and try again later.'); + } else { + console.error(error.message); + } +} +``` + +--- + +## Error Handling + +When using the Media Hosting API npm package, you may encounter various errors. It's essential to handle errors gracefully in your application. The package throws errors with descriptive messages to help you troubleshoot issues. + +### Example + +```javascript +const mediaHostingApi = require('media-hosting-api'); + +try { + const result = mediaHostingApi.checkMediaFileExistence('nonexistent'); + console.log(result); +} catch (error) { + console.error(error.message); +} +``` + +Output: + +```json +{ + "error": "Media file not found." +} +``` + +--- + +## Contributing to the Package + +If you find any issues or have suggestions for improvements, feel free to contribute to the Media Hosting API npm package on its [GitHub repository](https://github.com/yourusername/media-hosting-api). + +--- + +## Conclusion + +You've now explored the key features and usage of the Media Hosting API npm package. Integrate these functions into your Node.js applications for efficient media file hosting and management. If you have any questions or need further assistance, refer to the package documentation or reach out to the community on the [support forum](https://community.mediahostingapi.com). + +Happy coding with Media Hosting API! \ No newline at end of file