Coder Social home page Coder Social logo

iptv-checker's Introduction

IPTV Checker Build Status

Node.js CLI tool for checking links in IPTV playlists.

This tool is based on the ffmpeg library, so you need to install it on your computer first. You can find the right installer for your system here: https://www.ffmpeg.org/download.html

Usage

CLI

npm install -g iptv-checker

Check local playlist file:

iptv-checker /path-to-playlist/example.m3u

Check playlist URL:

iptv-checker https://some-playlist.lol/list.m3u

Pipe playlist from stdin:

cat ~/some-playlist.m3u | iptv-checker

Arguments:

  • -o, --output: change default output directory
  • -t, --timeout: specifies the number of milliseconds before the request will be aborted (default to 60000)
  • -a, --user-agent: set custom HTTP User-Agent
  • -k, --insecure: allow insecure connections when using SSL
  • -p, --parallel: Batch size of channels to check concurrently (default to 1)

Module

npm install iptv-checker
var IPTVChecker = require('iptv-checker')

var checker = new IPTVChecker()

// using playlist url
checker.checkPlaylist('https://some-playlist.lol/list.m3u').then(results => {
  console.log(results)
})

// using local path
checker.checkPlaylist('path/to/playlist.m3u').then(results => {
  console.log(results)
})

// using playlist as string
checker.checkPlaylist(string).then(results => {
  console.log(results)
})

Results

On success:

{
  header: {
    attrs: {},
    raw: '#EXTM3U x-tvg-url=""'
  },
  items: [
    {
      name: 'KBSV/AssyriaSat (720p) [Not 24/7]',
      tvg: {
        id: 'KBSVAssyriaSat.us',
        name: '',
        logo: 'https://i.imgur.com/zEWSSdf.jpg',
        url: '',
        rec: ''
      },
      group: {
        title: 'General'
      },
      http: {
        referrer: '',
        'user-agent': ''
      },
      url: 'http://66.242.170.53/hls/live/temp/index.m3u8',
      raw: '#EXTINF:-1 tvg-id="KBSVAssyriaSat.us" tvg-logo="https://i.imgur.com/zEWSSdf.jpg" group-title="General",KBSV/AssyriaSat (720p) [Not 24/7]\r\nhttp://66.242.170.53/hls/live/temp/index.m3u8',
      line: 2,
      catchup: {
        type: '',
        days: '',
        source: ''
      },
      timeshift: '',
      status: {
        ok: true,
        metadata: {
          streams: [
            {
              index: 0,
              codec_name: 'h264',
              codec_long_name: 'H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10',
              profile: 'High',
              codec_type: 'video',
              codec_tag_string: '[27][0][0][0]',
              codec_tag: '0x001b',
              width: 1280,
              height: 720,
              coded_width: 1280,
              coded_height: 720,
              closed_captions: 0,
              has_b_frames: 2,
              pix_fmt: 'yuv420p',
              level: 31,
              chroma_location: 'left',
              refs: 1,
              is_avc: 'false',
              nal_length_size: '0',
              r_frame_rate: '30/1',
              avg_frame_rate: '0/0',
              time_base: '1/90000',
              start_pts: 943358850,
              start_time: '10481.765000',
              bits_per_raw_sample: '8',
              disposition: {
                default: 0,
                dub: 0,
                original: 0,
                comment: 0,
                lyrics: 0,
                karaoke: 0,
                forced: 0,
                hearing_impaired: 0,
                visual_impaired: 0,
                clean_effects: 0,
                attached_pic: 0,
                timed_thumbnails: 0
              },
              tags: {
                variant_bitrate: '400000'
              }
            },
            //...
          ],
          format: {
            filename: 'http://66.242.170.53/hls/live/temp/index.m3u8',
            nb_streams: 2,
            nb_programs: 1,
            format_name: 'hls',
            format_long_name: 'Apple HTTP Live Streaming',
            start_time: '10481.560589',
            size: '214',
            probe_score: 100
          },
          requests: [
            {
              method: 'GET',
              url: 'http://66.242.170.53/hls/live/temp/index.m3u8',
              headers: {
                'User-Agent': 'Lavf/58.76.100',
                Accept: '*/*',
                Range: 'bytes=0-',
                Connection: 'close',
                Host: '66.242.170.53',
                'Icy-MetaData': '1'
              }
            },
            //...
          ]
        }
      }
    },
    //...
  ]
}

On error:

{
  header: {
    attrs: {},
    raw: '#EXTM3U x-tvg-url=""'
  },
  items: [
    {
      name: 'Addis TV (720p)',
      tvg: {
        id: 'AddisTV.et',
        name: '',
        logo: 'https://i.imgur.com/KAg6MOI.png',
        url: '',
        rec: ''
      },
      group: {
        title: ''
      },
      http: {
        referrer: '',
        'user-agent': ''
      },
      url: 'https://rrsatrtmp.tulix.tv/addis1/addis1multi.smil/playlist.m3u8',
      raw: '#EXTINF:-1 tvg-id="AddisTV.et" tvg-logo="https://i.imgur.com/KAg6MOI.png" group-title="Undefined",Addis TV (720p)\\r\\nhttps://rrsatrtmp.tulix.tv/addis1/addis1multi.smil/playlist.m3u8',
      line: 2,
      catchup: {
        type: '',
        days: '',
        source: ''
      },
      timeshift: '',
      status: {
        ok: false,
        code: 'HTTP_REQUEST_TIMEOUT',
        message: 'HTTP 408 Request Timeout',
      }
    },
    //...
  ]
}

Error codes

A full list of the error codes used and their descriptions can be found here.

Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an issue or a pull request.

License

MIT

iptv-checker's People

Contributors

denghongcai avatar detroitenglish avatar freearhey avatar yadalik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iptv-checker's Issues

Time Out

Microsoft Windows [Version 10.0.19042.1110]
(c) Microsoft Corporation. All rights reserved.

C:\Users\acer>iptv-checker C:\Users\acer\Desktop\test.m3u
[===] 3/3 (100%)

Total: 3
Online: 0
Offline: 3
Duplicates: 0

#EXTM3U
#EXTINF:-1, TV1 (Timed out)
https://rtmklik.rtm.gov.my/tv/1
#EXTINF:-1 ,TV2 (Timed out)
https://rtm1.secureswiftcontent.com/Origin01/ngrp:RTM1/playlist.m3u8
#EXTINF:-1 ,TV3 (Timed out)
https://stream-03.sg1.dailymotion.com/sec(_9ERdFwnAbs1GZsc1AwhHY634iz1M9H7ztC85bpw0JE)/dm/3/x6qp375/d/live-3.m3u8

[enhancement] add limit bandwidth usage

hi.. can you add bw usage for checking?
ie, i want check some playlist with limit 2Mb connection i have
and proxy for checking playlist. because some host blocked ip outside their country
thank you

multiple user agents in a single playlist

Hi there,

the streams in my example will only work with a specific user-agent. iptv-checker allows me to define a global user-agent. Is there a way to define the user-agents individually?

Would it be possible to respect the user agent defined in the #EXTVLCOPT attribute?

#EXTM3U

#EXTINF:-1,Stream 1
#EXTVLCOPT:http-user-agent=VLC/3.0.9.2
http://sample.net/stream1.m3u8

#EXTINF:-1,Stream 2
#EXTVLCOPT:http-user-agent=FooBar/1.2.3
http://sample.net/stream2.m3u8

iptv-checker -a 'VLC/3.0.9.2' -k sample.m3u

  • Stream 1 = Online
  • Stream 2 = Offline

iptv-checker -a 'FooBar/1.2.3' -k sample.m3u

  • Stream 1 = Offline
  • Stream 2 = Online

undefined

Hi. I've been attempting to use iptv-checker on some playlists, but I haven't been able to make it work. It keeps telling me undefined. I looked through the output files, and they only have #EXTM3U at the top of the file. Even with URLs, it gives unrealistic outputs. For example, one can test this with https://iptv-org.github.io/iptv/countries/iq.m3u, and there it says all channels are offline.

image

I have FFMPEG installed via Chocolatey and added to system PATH.

Can you please help me with this error? Thank you!

q&a

its possible execute this code in actions on github? without a machine local?

add MIT LICENSE

Hello. I'm packaging this software to Arch Linux (AUR).

I can't find an MIT license with your information. Please consider adding an MIT license with Copyright <YEAR> <COPYRIGHT HOLDER>. Thanks.

Redirects detection

Some links provided in playlists do nothing but redirection to a real source. Would be cool if there was a flag to replace redirects in online.m3u with a direct link that was used for a channel. This change can also improve duplication check

Getting an error when running

Hello,
I have just pulled down this as NPM module and trying to do a simple call (see code below)

var checker = require('iptv-checker')

checker.checkPlaylist('data/es.m3u').then(results => {
    console.log(results) 
})

but I get an error checker.checkPlaylist is not a function.

I have tried reinstalling and troubleshooting but don't understand why it throws this error. Is there something I am missing?

Server returned 4XX Client Error, but not one of 40(0,1,3,4)

Can we have an explicit error returned for 451 (same meaning as 403) error reported?

cuz now we get Server returned 4XX Client Error, but not one of 40(0,1,3,4) instead for it

image

451 is returned for geo-blocked content by some providers instead of 403 forbidden

Feature Request: Download or Pipe Playlists

Great work on this, @freearhey! IMO just two simple features could take this to the next level.

I suggest allowing users:

  1. to provide a URL of an .m3u playlists to download before checking.
  2. to pipe a playlist via command line into iptv-checker for processeing.

The first feature eliminates the need for locally stored playlists files, and the latter makes it simple to leverage iptv-checker with scripting languages e.g. Bash or Powershell.

If you're on board with the idea, I'm happy to implement and PR these features for ya myself 👍

Just let me know what you think - thanks!

Add a delay between checks

This seems to work well, but some IPTV providers appear to block the script after, for example, 10-12 checks. All the checks fail after that until you wait a few mins and run again.

Is it possible to add a delay parameter between requests?

Note that I experimented with the timeout parameter (while setting -p 1) without improving the ability to successfully all the channels in the M3U file.

Missing Test Script

Running npm run test should execute test/index.js; however, this file doesn't seem to exist 🤷‍♂️

If you already have this script for testing, then it just needs to be added to the repo.

Otherwise, again I'd be happy implement this myself (using something like ava?). Just let me know what you think!

Is testing RTP streams possible?

Hello,
I have an m3u file with RTP streams links. When I execute, the output is:

iptv-checker testliste.m3u

Total: 0
Online: 0
Offline: 0
Duplicates: 0

Here is my m3u file:

#EXTM3U
#EXTINF:0,rtp://239.193.132.161:1234
rtp://@239.193.132.161:1234
#EXTINF:0,rtp://239.193.128.33:1234
rtp://@239.193.128.33:1234

Note that the streams are on a private network.

My questions:

  1. Is the list badly formatted? I created it from VLC
  2. Are RTP streams supported?

Thank you

filter

howto filter m3u to leave only working links?

async function init() in crontab

when i use crontab, it failed, but in normal station, it succeed

/usr/lib/node_modules/iptv-checker/src/index.js:59
async function init()
^^^^^^^^

SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.runMain (module.js:611:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:160:9)

All sources in MacOS failed

OS:macos 12.0.1
version: 0.23

~/Downloads/check_m3u  iptv-checker ./GGTV424.m3u  ✔  18:15:12
[==============================================================================================================================================================] 417/417 (100%)

Total: 417
Online: 0
Offline: 417
Duplicates: 0
~/Downloads/check_m3u  cat ./GGTV424.m3u | iptv-checker  ✔  18:25:14
[==============================================================================================================================================================] 417/417 (100%)

Total: 417
Online: 0
Offline: 417
Duplicates: 0

All sources fail, and the source is fine.

mark as duplicate because same tv-logo cover

hi.. i have issue when check tv serial with same cover image source but different movie file source
iptv-checker mark as duplicate. so... iptv-checker only check one file with same image cover source. are this tool can't check playlist with same image cover source? this my playlist sample mark as duplicate. i have 60 eps with same cover

#EXTINF:-1 tvg-logo="" group-title="VOD MOVIES",Insya Allah Sah 2 (2018)
http://srv24.nf21.net:80/files/10-2018-11-04-dcbe1927ad12c18b3d39efe1e310b3b5.mp4
#EXTINF:-1 tvg-logo="" group-title="VOD MOVIES",Arini (2018)
http://srv19.nf21.net:80/files/15-2018-08-19-4e022676b9971cfac33a65d84288c01d.mp4
#EXTINF:-1 tvg-logo="" group-title="VOD MOVIES",Benyamin Biang Kerok (2018)
http://srv19.nf21.net:80/files/15-2018-08-14-2a88269fa86b8dab2575101a66eb0732.mp4
#EXTINF:-1 tvg-logo="" group-title="VOD MOVIES",Bodyguard Ugal-Ugalan (2018)
http://srv24.nf21.net:80/files/11-2018-11-09-4d0f5e263c6bc227c1b23c5145c32713.mp4
#EXTINF:-1 tvg-logo="" group-title="VOD MOVIES",Flight 555 (2018)
http://srv19.nf21.net:80/files/15-2018-08-14-f0ddc7cdffd608547912ad3a1b33056f.mp4

different resaults from same Commands

[root@xzyjs ~]# iptv-checker /sample/* -o /sample/iptv_check -t 60000

Total: 156. Online: 83. Offline: 67. Duplicates: 6.
[root@xzyjs ~]# iptv-checker /sample/* -o /sample/iptv_check -t 60000

Total: 156. Online: 84. Offline: 66. Duplicates: 6.

Fetch api warning.

How can I disable the Fetch API warning?

(node:377555) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

iptv-checker -o Erro

iptv-checker -o
internal/fs/utils.js:525
throw new ERR_INVALID_ARG_TYPE(propName, ['string', 'Buffer', 'URL'], path);
^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type boolean
at Object.mkdirSync (fs.js:815:10)
at Object. (/usr/lib/node_modules/iptv-checker/src/index.js:42:6)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11 {
code: 'ERR_INVALID_ARG_TYPE'
}

and also

iptv-checker -o /www/wwwroot/sample
(node:1307) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be one of type string, Buffer, or URL. Received type object
at Object.openSync (fs.js:432:10)
at Object.readFileSync (fs.js:342:35)
at readFile (/usr/lib/node_modules/iptv-checker/src/helper.js:15:13)
at Object.parsePlaylist (/usr/lib/node_modules/iptv-checker/src/helper.js:19:19)
at init (/usr/lib/node_modules/iptv-checker/src/index.js:63:25)
at Object. (/usr/lib/node_modules/iptv-checker/src/index.js:57:1)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
(node:1307) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:1307) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Feature: Extend for modular compatibility

I'd love to utilize this package as a module in other scripts in addition to its current form as a standalone CMD tool.

My basic idea as a module would be to accept e.g. an array of items from iptv-playlist-parser, process them with ffprobe, append status info and metadata to each item, and finally return the array of freshly-checked items.

Of course, nothing would change if called via command line. But if it's requireed by another script, it'll, for example, disable everything file-system related.

Here's a working example branch. Run npm run module-example, and a script will pass an array of items, and a URL into two imported iptv-checker instances respectively.

I guess the most important question is: do you want to work together on this, or would you rather I forked and created a separate package?

I'm fine with either - your repo, your call! 😎

Timeout Validation

In the last release, the timeout check was disabled to prevent duplication on the output.

The problem is that the built-in timer in ffprobe does not work in most cases and can delay the check of one broadcast to infinity.

But what makes the situation even more complicated is that ffprobe also lacks a built-in process stop mechanism. That is, even if you run a regular timer parallel to the main check and it finishes the countdown earlier, you have no way to stop the check in ffprobe and prevent duplicates in the output.

If there is any good solution, I will definitely turn on the timeout check back, but at this point I decided to just turn it off completely.

Strange Error

Here is what I meet
when I was trying to run

iptv-checker -o output https://iptv-org.github.io/iptv/languages/zho.m3u

and I got this result

Total: 737
Online: 0
Offline: 737
Duplicates: 0

and I read your issue, trying to run this

ffprobe -of json -hide_banner -timeout '60000000' 'https://iptv-org.github.io/iptv/languages/zho.m3u'

then I got this result

{
https://iptv-org.github.io/iptv/languages/zho.m3u: Invalid data found when processing input

}

I think I need your help

Side-Effect: Overriding the default ffprobe User-Agent header

When not defined as an option, the current command passed to ffprobe overrides ffprobe's default User-Agent header (with User-Agent: "undefined", I believe).

According to the ffprobe docs on the -user_agent option:

If not specified the protocol will use a [User-Agent header] string describing the libavformat build. ("Lavf/")

Overriding the standard UA-header by default could result in false-negatives from stream providers that sniff (or worse, whitelist) the User-Agent of incoming connections.

PR inbound...

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.