Skip to content

Commit fe95755

Browse files
authored
Merge pull request #950 from alpgul/newFeature-webParserWithPattern
New feature web parser with pattern
2 parents f45ef38 + 2b34dec commit fe95755

20 files changed

+467
-36
lines changed

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ set(IPTV_SOURCES src/addon.cpp
4545
src/iptvsimple/utilities/Logger.cpp
4646
src/iptvsimple/utilities/SettingsMigration.cpp
4747
src/iptvsimple/utilities/StreamUtils.cpp
48-
src/iptvsimple/utilities/WebUtils.cpp)
48+
src/iptvsimple/utilities/WebUtils.cpp
49+
src/iptvsimple/utilities/WebStreamExtractor.cpp
50+
src/iptvsimple/utilities/CurlUtils.cpp
51+
)
4952

5053
set(IPTV_HEADERS src/addon.h
5154
src/IptvSimple.h
@@ -76,7 +79,10 @@ set(IPTV_HEADERS src/addon.h
7679
src/iptvsimple/utilities/StreamUtils.h
7780
src/iptvsimple/utilities/TimeUtils.h
7881
src/iptvsimple/utilities/WebUtils.h
79-
src/iptvsimple/utilities/XMLUtils.h)
82+
src/iptvsimple/utilities/XMLUtils.h
83+
src/iptvsimple/utilities/WebStreamExtractor.h
84+
src/iptvsimple/utilities/CurlUtils.h
85+
)
8086

8187
addon_version(pvr.iptvsimple IPTV)
8288
add_definitions(-DIPTV_VERSION=${IPTV_VERSION})

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ Here’s some examples of how the different formats would look:
408408
#### M3U format elements:
409409

410410
```
411-
#EXTM3U tvg-shift="-4.5" x-tvg-url="http://path-to-xmltv/guide.xml catchup-correction="-2.5"
411+
#EXTM3U tvg-shift="-4.5" x-tvg-url="http://path-to-xmltv/guide.xml" catchup-correction="-2.5"
412412
#EXTINF:0 tvg-id="channel-x" tvg-name="Channel_X" group-title="Entertainment" tvg-chno="10" tvg-logo="http://path-to-icons/channel-x.png" radio="true" tvg-shift="-3.5",Channel X
413413
#EXTVLCOPT:program=745
414414
#KODIPROP:key=val
@@ -451,6 +451,10 @@ http://path-to-stream/live/channel-m.mkv
451451
http://path-to-stream/live/channel-n.mkv
452452
#EXTINF:-1 media-dir="/movies/scifi",Channel O
453453
http://path-to-stream/live/channel-o.mkv
454+
#EXTINF:-1 tvg-name="Channel-P", Channel-P
455+
#WEBPROP:web-regex="([^"]+\.m3u8)"
456+
#WEBPROP:web-headers=user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36&referer:https://google.com/
457+
@http://path-to-stream/live/channel-p.html|user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
454458
```
455459

456460
*Explanation for Catchup entries*
@@ -528,8 +532,12 @@ http://path-to-stream/live/channel-z.ts
528532
- `#EXTGRP`: A semi-colon separted list of channel groups. Note that this is a begin directive, i.e. all channels following this directive will have these groups until an empty `#EXTGRP` directive is reached. These groupings wil also be reset by any `group-title` tag for an `#EXTINF` channel directive.
529533
- `#KODIPROP`: A single property in the format `key=value` that can be passed to Kodi. Multiple can be passed each on a separate line.
530534
- `#EXTVLCOPT`: A single property in the format `key=value` that can be passed to Kodi. Multiple can be passed each on a separate line. Note that if either a `http-user-agent` or a `http-referrer` property is found it will added to the URL as a HTTP header as `user-agent` or `referrer` respectively if not already provided in the URL. These two fields specifically will be dropped as properties whether or not they are added as header values. They will be added in the same format as the `URL` below.
535+
- `#WEBPROP`: Properties used for web scraping streams from HTML pages. Multiple can be passed each on a separate line.
536+
- `web-regex`: A regular expression pattern to extract the stream URL from the HTML content. The first capture group will be used as the stream URL. The URL must be captured within parentheses in the regex pattern, e.g. "([^"]+\.m3u8)".
537+
- `web-headers`: HTTP headers to be used when making the request to the web page. Format is `name1:value1&name2:value2`.
531538
- `#EXT-X-PLAYLIST-TYPE`: If this element is present with a value of `VOD` (Video on Demand) the stream is marked as not being live.
532539
- `URL`: The final line in each channel stanza is the URL used for the stream. Appending `|user-agent=<agent-name>` will change the user agent. Other HTTP header fields can be set in the same fashion: `|name1=val1&name2=val2` etc. The header fields supported in this way by Kodi can be found [here](#http-header-fields-supported-by-kodi). If you want to pass custom headers that are not supported by Kodi you need to prefix them with an `!`, for example: : `|!name1=val1&!name2=val2`.
540+
- `@`: When a URL starts with '@' symbol (e.g. '@http://path-to-stream/live/channel-p.html'), it indicates that the URL points to a web page that contains the actual stream URL. The addon will attempt to extract the stream URL from this web page using either the provided `web-regex` pattern or default patterns. This is useful when the actual stream URL is embedded within a web page rather than being directly accessible.
533541

534542
When processing an XMLTV file the addon will attempt to find a channel loaded from the M3U that matches the EPG channel. It will cycle through the full set of M3U channels checking for one condition on each pass. The first channel found to match is the channel chosen for this EPG channel data.
535543

depends/common/zlib/01-build-static.patch

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
--- a/CMakeLists.txt
22
+++ b/CMakeLists.txt
3-
@@ -147,10 +147,11 @@
3+
@@ -149,12 +149,12 @@
44
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
55
endif(MINGW)
6-
6+
77
-add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
8+
+add_library(zlib ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
9+
target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
810
-add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
11+
-target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
912
-set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
1013
-set_target_properties(zlib PROPERTIES SOVERSION 1)
11-
+add_library(zlib ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
1214
+if(BUILD_SHARED_LIBS)
1315
+ set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
1416
+ set_target_properties(zlib PROPERTIES SOVERSION 1)
1517
+endif()
16-
18+
1719
if(NOT CYGWIN)
1820
# This property causes shared libraries on Linux to have the full version
19-
@@ -165,7 +166,7 @@
20-
21+
@@ -169,7 +169,7 @@
22+
2123
if(UNIX)
2224
# On unix-like platforms the library is almost always called libz
2325
- set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
2426
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
25-
if(NOT APPLE)
27+
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
2628
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
2729
endif()
28-
@@ -175,7 +176,7 @@
30+
@@ -179,7 +179,7 @@
2931
endif()
30-
32+
3133
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
3234
- install(TARGETS zlib zlibstatic
3335
+ install(TARGETS zlib
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
--- a/CMakeLists.txt
22
+++ b/CMakeLists.txt
3-
@@ -226,25 +226,3 @@ endif()
4-
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
3+
@@ -194,25 +194,3 @@ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
54
install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
65
endif()
7-
-
6+
87
-#============================================================================
98
-# Example binaries
109
-#============================================================================
10+
-if(ZLIB_BUILD_EXAMPLES)
11+
- add_executable(example test/example.c)
12+
- target_link_libraries(example zlib)
13+
- add_test(example example)
1114
-
12-
-add_executable(example test/example.c)
13-
-target_link_libraries(example zlib)
14-
-add_test(example example)
15-
-
16-
-add_executable(minigzip test/minigzip.c)
17-
-target_link_libraries(minigzip zlib)
15+
- add_executable(minigzip test/minigzip.c)
16+
- target_link_libraries(minigzip zlib)
1817
-
19-
-if(HAVE_OFF64_T)
20-
- add_executable(example64 test/example.c)
21-
- target_link_libraries(example64 zlib)
22-
- set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
23-
- add_test(example64 example64)
18+
- if(HAVE_OFF64_T)
19+
- add_executable(example64 test/example.c)
20+
- target_link_libraries(example64 zlib)
21+
- set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
22+
- add_test(example64 example64)
2423
-
25-
- add_executable(minigzip64 test/minigzip.c)
26-
- target_link_libraries(minigzip64 zlib)
27-
- set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
24+
- add_executable(minigzip64 test/minigzip.c)
25+
- target_link_libraries(minigzip64 zlib)
26+
- set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
27+
- endif()
2828
-endif()
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--- a/CMakeLists.txt
22
+++ b/CMakeLists.txt
3-
@@ -12,7 +12,7 @@ set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation direc
3+
@@ -11,7 +11,7 @@
44
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
55
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
66
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
@@ -9,4 +9,3 @@
99

1010
include(CheckTypeSize)
1111
include(CheckFunctionExists)
12-

depends/common/zlib/zlib.sha256

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d14c38e313afc35a9a8760dadf26042f51ea0f5d154b0630a31da0540107fb98
1+
38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32

depends/common/zlib/zlib.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
zlib http://mirrors.kodi.tv/build-deps/sources/zlib-1.2.13.tar.xz
1+
zlib https://www.zlib.net/zlib-1.3.1.tar.xz

pvr.iptvsimple/addon.xml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<addon
33
id="pvr.iptvsimple"
4-
version="21.10.2"
4+
version="21.11.0"
55
name="IPTV Simple Client"
66
provider-name="nightik and Ross Nicholson">
77
<requires>@ADDON_DEPENDS@

pvr.iptvsimple/changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v21.11.0
2+
- Add support for web stream extraction from HTML content
3+
- Add support for custom regex patterns for web stream extraction
4+
15
v21.10.2
26
- Add debug logging for EPG loads
37

src/IptvSimple.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ PVR_ERROR IptvSimple::GetChannelStreamProperties(const kodi::addon::PVRChannel&
247247
else
248248
streamURL = m_catchupController.ProcessStreamUrl(m_currentChannel);
249249

250+
streamURL = StreamUtils::WebStreamExtractor(streamURL, m_currentChannel);
250251
StreamUtils::SetAllStreamProperties(properties, m_currentChannel, streamURL, catchupUrl.empty(), catchupProperties, m_settings);
251252

252253
Logger::Log(LogLevel::LEVEL_INFO, "%s - Live %s URL: %s", __FUNCTION__, catchupUrl.empty() ? "Stream" : "Catchup", WebUtils::RedactUrl(streamURL).c_str());
@@ -425,6 +426,7 @@ PVR_ERROR IptvSimple::GetRecordingStreamProperties(const kodi::addon::PVRRecordi
425426

426427
if (!mediaEntry.GetMediaEntryId().empty() && !url.empty())
427428
{
429+
url = StreamUtils::WebStreamExtractor(url, mediaEntry);
428430
StreamUtils::SetAllStreamProperties(properties, mediaEntry, url, m_settings);
429431

430432
return PVR_ERROR_NO_ERROR;

0 commit comments

Comments
 (0)