[GH-ISSUE #20] Add RESTful API #17

Closed
opened 2026-02-25 20:32:11 +03:00 by kerem · 8 comments
Owner

Originally created by @diaskooo on GitHub (Jan 22, 2015).
Original GitHub issue: https://github.com/asapach/peerflix-server/issues/20

Add to peerflix-server support RESTful API be able to manage removed peerflix-server

  1. Adding a torrent or Magnet link and delete from the list
  2. Preparation of the download status and impact without vebsokket
  3. Information about the contents of a torrent
  4. Information about video codec, resolution, bitrate, etc.
  5. и т.д )
Originally created by @diaskooo on GitHub (Jan 22, 2015). Original GitHub issue: https://github.com/asapach/peerflix-server/issues/20 Add to peerflix-server support RESTful API be able to manage removed peerflix-server 1) Adding a torrent or Magnet link and delete from the list 2) Preparation of the download status and impact without vebsokket 3) Information about the contents of a torrent 4) Information about video codec, resolution, bitrate, etc. 5) и т.д )
kerem 2026-02-25 20:32:11 +03:00
Author
Owner

@asapach commented on GitHub (Jan 22, 2015):

It does already have an API, although not really documented:

  1. POST /torrents with JSON like {"link":"magnet link or URL"} - will add a new torrent
    DELETE /torrents/{infoHash} will delete the torrent
  2. It will automatically start downloading when you request a file
  3. GET /torrents will return all torrents and GET /torrents/{infoHash} one torrent
  4. That would require downloading the files first (at least partially) and integrating with ffmpeg or some other external tool, and I'm not sure it's a good idea. Suggestions are welcome.

Do you have a particular scenario you would like to use the API in?

<!-- gh-comment-id:71065125 --> @asapach commented on GitHub (Jan 22, 2015): It does already have an API, although not really documented: 1. `POST /torrents` with JSON like `{"link":"magnet link or URL"}` - will add a new torrent `DELETE /torrents/{infoHash}` will delete the torrent 2. It will automatically start downloading when you request a file 3. `GET /torrents` will return all torrents and `GET /torrents/{infoHash}` one torrent 4. That would require downloading the files first (at least partially) and integrating with ffmpeg or some other external tool, and I'm not sure it's a good idea. Suggestions are welcome. Do you have a particular scenario you would like to use the API in?
Author
Owner

@diaskooo commented on GitHub (Jan 23, 2015):

From /torrents (POST, DELETE, GET) all works

Not enough GET /torrents/{infoHash}/stat - Information about running torrent Speed, Traffic, Peers, Queue. And working through WebSokket I do not like because of the limited SMART TV

  1. That would require downloading the files first (at least partially) and integrating with ffmpeg or some other external tool, and I'm not sure it's a good idea. Suggestions are welcome.

GET /torrents/{infoHash}/codec
This functionality is only active for distribution be used to display information about a file in the information section of a resolution, some ulcer 2.1 or 5.1, etc.

<!-- gh-comment-id:71240837 --> @diaskooo commented on GitHub (Jan 23, 2015): From /torrents (POST, DELETE, GET) all works Not enough GET /torrents/{infoHash}/stat - Information about running torrent Speed, Traffic, Peers, Queue. And working through WebSokket I do not like because of the limited SMART TV > 1. That would require downloading the files first (at least partially) and integrating with ffmpeg or some other external tool, and I'm not sure it's a good idea. Suggestions are welcome. GET /torrents/{infoHash}/codec This functionality is only active for distribution be used to display information about a file in the information section of a resolution, some ulcer 2.1 or 5.1, etc.
Author
Owner

@asapach commented on GitHub (Jan 24, 2015):

Added the /stats endpoint and released as v0.0.19
https://github.com/asapach/peerflix-server/blob/master/REST.md
Will investigate ffmpeg next.

<!-- gh-comment-id:71321338 --> @asapach commented on GitHub (Jan 24, 2015): Added the /stats endpoint and released as v0.0.19 https://github.com/asapach/peerflix-server/blob/master/REST.md Will investigate ffmpeg next.
Author
Owner

@asapach commented on GitHub (Jan 24, 2015):

Added support for ffmpeg in v0.0.20:

  • /torrents/{infoHash}/files/{path}?ffmpeg=probe - will run ffprobe and dump the JSON output containing the format and streams information. Limitation: ffprobe doesn't work with streams, so the file has to be at least partially downloaded, so that it could inspect the headers.
  • /torrents/{infoHash}/files/{path}?ffmpeg=remux - will run ffmpeg and remux the file to MP4 - meaning the video stream will be copied and the audio stream will be converted to AAC (this should make it work in most browsers). Limitation: the video output doesn't support seeking, so you'll not be able to rewind.

To make it work you need to install ffmpeg: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#ffmpeg-and-ffprobe
On Windows you'll need to set FFMPEG_PATH and FFPROBE_PATH env variables (e.g. SET FFPROBE_PATH=C:\ffmpeg\bin\ffprobe.exe
On Ubuntu you'll need to install the package from the ppa:

sudo apt-add-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg
<!-- gh-comment-id:71336799 --> @asapach commented on GitHub (Jan 24, 2015): Added support for ffmpeg in v0.0.20: - `/torrents/{infoHash}/files/{path}?ffmpeg=probe` - will run `ffprobe` and dump the JSON output containing the format and streams information. Limitation: `ffprobe` doesn't work with streams, so the file has to be at least partially downloaded, so that it could inspect the headers. - `/torrents/{infoHash}/files/{path}?ffmpeg=remux` - will run `ffmpeg` and remux the file to MP4 - meaning the video stream will be copied and the audio stream will be converted to AAC (this should make it work in most browsers). Limitation: the video output doesn't support seeking, so you'll not be able to rewind. To make it work you need to install ffmpeg: https://github.com/fluent-ffmpeg/node-fluent-ffmpeg#ffmpeg-and-ffprobe On Windows you'll need to set `FFMPEG_PATH` and `FFPROBE_PATH` env variables (e.g. `SET FFPROBE_PATH=C:\ffmpeg\bin\ffprobe.exe` On Ubuntu you'll need to install the package from the ppa: ``` sudo apt-add-repository ppa:jon-severinsson/ffmpeg sudo apt-get update sudo apt-get install ffmpeg ```
Author
Owner

@asapach commented on GitHub (Jan 24, 2015):

@diaskooo, could you please try it out and provide some feedback?

<!-- gh-comment-id:71336847 --> @asapach commented on GitHub (Jan 24, 2015): @diaskooo, could you please try it out and provide some feedback?
Author
Owner

@ghost commented on GitHub (Mar 17, 2015):

I'll try feature with converting to MP4, but is it possible to add ability for rewinding (перемотка) video ?

<!-- gh-comment-id:82012739 --> @ghost commented on GitHub (Mar 17, 2015): I'll try feature with converting to MP4, but is it possible to add ability for rewinding (перемотка) video ?
Author
Owner

@asapach commented on GitHub (Mar 17, 2015):

In order to make seek/rewind work, the encoder needs to build the index that maps time to position (byte offset) in the file. For example 0:00:30 could map to offset 65536 in the stream. This allows the video player to jump directly to the requested position without having to make guesses or search the stream for timecodes. Unfortunately it's impossible to build the index on the fly: at least one full pass is required.

<!-- gh-comment-id:82252626 --> @asapach commented on GitHub (Mar 17, 2015): In order to make seek/rewind work, the encoder needs to build the index that maps time to position (byte offset) in the file. For example `0:00:30` could map to offset `65536` in the stream. This allows the video player to jump directly to the requested position without having to make guesses or search the stream for timecodes. Unfortunately it's impossible to build the index on the fly: at least one full pass is required.
Author
Owner

@asapach commented on GitHub (May 16, 2015):

Merging this thread into #19

<!-- gh-comment-id:102700367 --> @asapach commented on GitHub (May 16, 2015): Merging this thread into #19
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/peerflix-server#17
No description provided.