Skip to content

Commit 3ced7f7

Browse files
committed
new protocol YT (mandatory requirement is yt-dlp)
1 parent c16fffb commit 3ced7f7

20 files changed

+314
-11
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ all-redirect: all
8181
OBJS = $(PLUGIN).o common.o config.o device.o pidscanner.o \
8282
protocolcurl.o protocolext.o protocolfile.o protocolhttp.o \
8383
protocoludp.o sectionfilter.o setup.o sidscanner.o socket.o \
84-
protocolm3u.o protocolradio.o protocolstream.o \
84+
protocolm3u.o protocolradio.o protocolstream.o protocolyt.o \
8585
m3u8handler.o process.o process_unix.o streambasehandler.o \
8686
source.o statistics.o streamer.o radioimage.o checkurl.o
8787

checkurl.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ void CheckURL::executeChecks() {
9393
u = itp.Address();
9494
break;
9595

96+
case cIptvTransponderParameters::eProtocolYT:
97+
u = itp.Address();
98+
break;
99+
96100
case cIptvTransponderParameters::eProtocolRadio:
97101
case cIptvTransponderParameters::eProtocolStream:
98102
u = itp.Address();

device.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ cIptvDevice::cIptvDevice(unsigned int indexP)
4242
pM3UProtocolM = new cIptvProtocolM3U();
4343
pRadioProtocolM = new cIptvProtocolRadio();
4444
pStreamProtocolM = new cIptvProtocolStream();
45+
pYTProtocolM = new cIptvProtocolYT();
4546
pPidScannerM = new cPidScanner();
4647
// Start section handler for iptv device
4748
pIptvSectionM = new cIptvSectionFilterHandler(deviceIndexM, bufsize + 1);
@@ -81,6 +82,7 @@ cIptvDevice::~cIptvDevice() {
8182
DELETE_POINTER(pM3UProtocolM);
8283
DELETE_POINTER(pRadioProtocolM);
8384
DELETE_POINTER(pStreamProtocolM);
85+
DELETE_POINTER(pYTProtocolM);
8486
DELETE_POINTER(tsBufferM);
8587

8688
// Close dvr fifo
@@ -328,6 +330,10 @@ bool cIptvDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP) {
328330
protocol = pStreamProtocolM;
329331
break;
330332

333+
case cIptvTransponderParameters::eProtocolYT:
334+
protocol = pYTProtocolM;
335+
break;
336+
331337
default:error("Unrecognized IPTV protocol: %s", channelP->Parameters());
332338
return false;
333339
break;

device.h

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "protocolm3u.h"
1919
#include "protocolradio.h"
2020
#include "protocolstream.h"
21+
#include "protocolyt.h"
2122
#include "streamer.h"
2223
#include "sectionfilter.h"
2324
#include "pidscanner.h"
@@ -52,6 +53,7 @@ class cIptvDevice : public cDevice, public cIptvPidStatistics, public cIptvBuffe
5253
cIptvProtocolRadio *pRadioProtocolM;
5354
cIptvProtocolStream *pStreamProtocolM;
5455
cIptvStreamer *pIptvStreamerM;
56+
cIptvProtocolYT *pYTProtocolM;
5557
cIptvSectionFilterHandler *pIptvSectionM;
5658
cPidScanner *pPidScannerM;
5759
cSidScanner *pSidScannerM;

m3u8handler.cpp

+63
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,69 @@ std::vector<std::string> M3u8Handler::split(const std::string &s, char delim) {
3737
return result;
3838
}
3939

40+
m3u_stream M3u8Handler::parseYT(const std::string &webUri) {
41+
std::string useUriVideo;
42+
std::string useUriAudio;
43+
44+
std::vector<std::string> callStr{
45+
IptvConfig.GetYtdlpPath(), "--get-url",
46+
"-f", "(bv*[vcodec~='^((he|a)vc|h26[45])']+ba[ext=m4a]/b[ext=mp4])", webUri
47+
};
48+
49+
std::string newUri;
50+
auto handler = new TinyProcessLib::Process(callStr, "",
51+
[&newUri](const char *bytes, size_t n) {
52+
std::string result = std::string(bytes, n);
53+
debug1("yt-dlp found URL %s\n", result.c_str());
54+
newUri = std::string(bytes, n);
55+
},
56+
57+
[](const char *bytes, size_t n) {
58+
std::string msg = std::string(bytes, n);
59+
debug1("yt-dlp Error: %s\n", msg.c_str());
60+
},
61+
62+
true
63+
);
64+
65+
int exitStatus = handler->get_exit_status();
66+
if (exitStatus!=0) {
67+
debug1("yt-dlp throws an error, abort\n");
68+
m3u_stream result;
69+
result.width = result.height = 0;
70+
return result;
71+
}
72+
73+
// check if the uri contains video/audio URL or if it's a simple URL
74+
auto m = newUri.find('\n');
75+
if (m == std::string::npos) {
76+
// only video
77+
useUriVideo = newUri;
78+
useUriAudio = "";
79+
} else {
80+
// audio / video
81+
useUriVideo = newUri.substr(0, m);
82+
useUriAudio = newUri.substr(m+1);
83+
}
84+
85+
// set dummy values
86+
m3u_stream result;
87+
result.width = 1920;
88+
result.height = 1080;
89+
result.url = useUriVideo;
90+
91+
if (!useUriAudio.empty()) {
92+
struct media audio;
93+
audio.uri = useUriAudio;
94+
audio.name = "audio";
95+
audio.language = "C";
96+
97+
result.audio.emplace_back(audio);
98+
}
99+
100+
return result;
101+
}
102+
40103
m3u_stream M3u8Handler::parseM3u(const std::string &webUri, int useYtdlp) {
41104
std::string useUri;
42105

m3u8handler.h

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class M3u8Handler {
3636
public:
3737
explicit M3u8Handler();
3838
static m3u_stream parseM3u(const std::string &uri, int useYtdlp);
39+
static m3u_stream parseYT(const std::string &webUri);
3940

4041
static void printStream(const m3u_stream& stream);
4142

po/ca_ES.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: vdr-iptv 2.4.0\n"
99
"Report-Msgid-Bugs-To: <see README>\n"
10-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
10+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1111
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1212
"Last-Translator: Gabriel Bonich <[email protected]>\n"
1313
"Language-Team: Catalan <[email protected]>\n"
@@ -145,6 +145,9 @@ msgstr "RADIO"
145145
msgid "STREAM"
146146
msgstr "STREAM"
147147

148+
msgid "YT"
149+
msgstr ""
150+
148151
msgid "Rid"
149152
msgstr "Rid"
150153

po/de_DE.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: vdr-iptv 2.4.0\n"
1010
"Report-Msgid-Bugs-To: <see README>\n"
11-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
11+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1212
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1313
"Last-Translator: Frank Neumann <[email protected]>\n"
1414
"Language-Team: German <[email protected]>\n"
@@ -146,6 +146,9 @@ msgstr "RADIO"
146146
msgid "STREAM"
147147
msgstr "STREAM"
148148

149+
msgid "YT"
150+
msgstr ""
151+
149152
msgid "Rid"
150153
msgstr "Rid"
151154

po/es_ES.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: vdr-iptv 2.4.0\n"
99
"Report-Msgid-Bugs-To: <see README>\n"
10-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
10+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1111
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1212
"Last-Translator: Gabriel Bonich <[email protected]>\n"
1313
"Language-Team: Spanish <[email protected]>\n"
@@ -145,6 +145,9 @@ msgstr "RADIO"
145145
msgid "STREAM"
146146
msgstr "STREAM"
147147

148+
msgid "YT"
149+
msgstr ""
150+
148151
msgid "Rid"
149152
msgstr "Rid"
150153

po/fi_FI.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: vdr-iptv 2.4.0\n"
99
"Report-Msgid-Bugs-To: <see README>\n"
10-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
10+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1111
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1212
"Last-Translator: Rolf Ahrenberg\n"
1313
"Language-Team: Finnish <[email protected]>\n"
@@ -144,6 +144,9 @@ msgstr "RADIO"
144144
msgid "STREAM"
145145
msgstr "STREAM"
146146

147+
msgid "YT"
148+
msgstr ""
149+
147150
msgid "Rid"
148151
msgstr "Radio-ID"
149152

po/fr_FR.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: vdr-iptv 2.4.0\n"
1010
"Report-Msgid-Bugs-To: <see README>\n"
11-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
11+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1212
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1313
"Last-Translator: NIVAL Michaël <[email protected]>\n"
1414
"Language-Team: French <[email protected]>\n"
@@ -146,6 +146,9 @@ msgstr "RADIO"
146146
msgid "STREAM"
147147
msgstr "STREAM"
148148

149+
msgid "YT"
150+
msgstr ""
151+
149152
msgid "Rid"
150153
msgstr "Rid"
151154

po/it_IT.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: vdr-iptv 2.4.0\n"
99
"Report-Msgid-Bugs-To: <see README>\n"
10-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
10+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1111
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1212
"Last-Translator: Diego Pierotto <[email protected]>\n"
1313
"Language-Team: Italian <[email protected]>\n"
@@ -145,6 +145,9 @@ msgstr "RADIO"
145145
msgid "STREAM"
146146
msgstr "STREAM"
147147

148+
msgid "YT"
149+
msgstr ""
150+
148151
msgid "Rid"
149152
msgstr "Rid"
150153

po/lt_LT.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: vdr-iptv 2.4.0\n"
99
"Report-Msgid-Bugs-To: <see README>\n"
10-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
10+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1111
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1212
"Last-Translator: Valdemaras Pipiras\n"
1313
"Language-Team: Lithuanian <[email protected]>\n"
@@ -144,6 +144,9 @@ msgstr "RADIO"
144144
msgid "STREAM"
145145
msgstr "STREAM"
146146

147+
msgid "YT"
148+
msgstr ""
149+
147150
msgid "Rid"
148151
msgstr "Radio-ID"
149152

po/nl_NL.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: vdr-iptv 2.4.0\n"
99
"Report-Msgid-Bugs-To: <see README>\n"
10-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
10+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1111
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1212
"Last-Translator: Carel\n"
1313
"Language-Team: Dutch <[email protected]>\n"
@@ -144,6 +144,9 @@ msgstr "RADIO"
144144
msgid "STREAM"
145145
msgstr "STREAM"
146146

147+
msgid "YT"
148+
msgstr ""
149+
147150
msgid "Rid"
148151
msgstr "Rid"
149152

po/pl_PL.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: vdr-iptv 2.4.0\n"
99
"Report-Msgid-Bugs-To: <see README>\n"
10-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
10+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1111
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1212
"Last-Translator: Tomasz Maciej Nowak <[email protected]>\n"
1313
"Language-Team: Polish <[email protected]>\n"
@@ -145,6 +145,9 @@ msgstr "RADIO"
145145
msgid "STREAM"
146146
msgstr "STREAM"
147147

148+
msgid "YT"
149+
msgstr ""
150+
148151
msgid "Rid"
149152
msgstr "Rid"
150153

po/ru_RU.po

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: vdr-iptv 2.4.0\n"
99
"Report-Msgid-Bugs-To: <see README>\n"
10-
"POT-Creation-Date: 2024-09-01 12:35+0200\n"
10+
"POT-Creation-Date: 2024-09-01 16:31+0200\n"
1111
"PO-Revision-Date: 2018-04-15 04:15+0300\n"
1212
"Last-Translator: Alexander Gross <[email protected]>\n"
1313
"Language-Team: Russian <[email protected]>\n"
@@ -136,6 +136,9 @@ msgstr "RADIO"
136136
msgid "STREAM"
137137
msgstr "STREAM"
138138

139+
msgid "YT"
140+
msgstr ""
141+
139142
msgid "Rid"
140143
msgstr "Rid"
141144

0 commit comments

Comments
 (0)