GithubHelp home page GithubHelp logo

5l1v3r1 / youtube-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michaelbelgium/youtube-api

0.0 1.0 0.0 41 KB

A way to host your own API that converts youtube video's to mp3/mp4 and returns a download/stream link and information.

PHP 57.88% Hack 37.95% Dockerfile 4.18%

youtube-api's Introduction

Youtube-to-mp3-API

With these two php files you are able to create your own Youtube to MP3 API with ability to search also. See the wiki for examples.

Possible HTTP requests

GET - convert.php

Convert a video

Parameter Required Type Description
youtubelink Yes string The full youtubelink of the video you want to download.
format No (default = mp3) string: mp3 or mp4 The format to download
delete No string The youtubeid of which you want it to be deleted from storage on the server

Delete a downloaded video

Parameter Required Type Description
delete Yes string The youtubeid that has to be deleted from storage on the server
format No (default = mp3 & mp4) string: mp3 or mp4, leave empty to remove all The format of the video that has to be deleted

Possible youtubelinks

youtube.com/v/{vidid}
youtube.com/vi/{vidid}
youtube.com/?v={vidid}
youtube.com/?vi={vidid}
youtube.com/watch?v={vidid}
youtube.com/watch?vi={vidid}
youtu.be/{vidid}

GET - search.php

Parameter Required Type Description
q Yes string The query term to search for video's
max_results No integer The max results of search results u want to get

Possible HTTP responses

JSON - convert.php

Parameter Type Description
error boolean Whether or not an error occured
message string A simple message or the error message
Parameter Type Description
error boolean false
youtube_id string The youtube identifier
title string The title of the video that got converted
alt_title string A secondary title of the video
duration integer The duration of the video that got converted (in seconds)
file string The streamlink or downloadable mp3 file
uploaded_at object A Date object

JSON - search.php

Parameter Type Description
error boolean Whether or not an error occured
message string An error message
results array An array with MAX_RESULTS entries. Each entry has: the video id, the channel name of the video, the video title and the full url to the video

Software requirements

General installation

First we install the dependencies on the server, then website.

VPS

Website

  • Get a google developer api key
  • Go to your webserver files to run composer into
  • Run composer create-project michaelbelgium/youtube-to-mp3 [directoryname] - where directoryname is .. a directory where people can access the API from.

Configuration

search.php

define("MAX_RESULTS", 10); //max search results
define("API_KEY", ""); //google api key

convert.php

define("DOWNLOAD_FOLDER", "download/"); //the folder where files are accessable to download
define("DOWNLOAD_MAX_LENGTH", 0); //max video duration (in seconds) to be able to download, set to 0 to disable
define("LOG", false); //enable logging

docker-compose

You can deploy this API using docker-compose.yml and the Dockerfile to build from. Please add your google API Key to docker-compose.yml. It will expose port 80 from the container, out to port 80 on the host. This can also be changed using the same file.

How to run with docker-compose

Put docker-compose.yml and Dockerfile together in a new, empty folder. Then, run the following command to get it running

sudo docker-compose up -d

To stop:

sudo docker-compose down

youtube-api's People

Contributors

dennorske avatar michaelbelgium avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.