1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 pytestCheckHook,
6 setuptools,
7 pyloggermanager,
8 requests,
9 pym3u8downloader, # For package tests
10}:
11
12buildPythonPackage rec {
13 pname = "pym3u8downloader";
14 version = "0.1.8";
15 pyproject = true;
16
17 src = fetchFromGitHub {
18 owner = "coldsofttech";
19 repo = "pym3u8downloader";
20 tag = version;
21 hash = "sha256-VfNzHysvEVUNx8OK28v2l3QYTMn0ydE/LH+DBXpLfE8=";
22 };
23
24 build-system = [ setuptools ];
25
26 dependencies = [
27 pyloggermanager
28 requests
29 ];
30
31 pythonImportsCheck = [ "pym3u8downloader" ];
32
33 doCheck = false;
34
35 passthru = {
36 tests = {
37 pytest = pym3u8downloader.overridePythonAttrs (previousPythonAttrs: {
38 TEST_SERVER_PORT = "8000";
39
40 postPatch =
41 previousPythonAttrs.postPatch or ""
42 + ''
43 # Patch test data location
44 substituteInPlace tests/commonclass.py \
45 --replace-fail \
46 "f'https://raw.githubusercontent.com/coldsofttech/pym3u8downloader/{branch_name}/tests/files'" \
47 "'http://localhost:$TEST_SERVER_PORT/tests/files'"
48 # Patch the `is_internet_connected()` method
49 substituteInPlace pym3u8downloader/__main__.py \
50 --replace-fail "'http://www.github.com'" "'http://localhost:$TEST_SERVER_PORT'"
51 '';
52
53 doCheck = true;
54
55 nativeCheckInputs = [ pytestCheckHook ];
56
57 preCheck =
58 previousPythonAttrs.preCheck or ""
59 + ''
60 python3 -m http.server "$TEST_SERVER_PORT" &
61 TEST_SERVER_PID="$!"
62 '';
63
64 postCheck =
65 previousPythonAttrs.postCheck or ""
66 + ''
67 kill -s TERM "$TEST_SERVER_PID"
68 '';
69 });
70 };
71 };
72
73 meta = {
74 description = "Python class to download and concatenate video files from M3U8 playlists";
75 longDescription = ''
76 M3U8 Downloader is a Python class designed to
77 download and concatenate video files from M3U8 playlists.
78 This class provides functionality to handle M3U8 playlist files,
79 download video segments,
80 concatenate them into a single video file,
81 and manage various error conditions.
82 '';
83 homepage = "https://github.com/coldsofttech/pym3u8downloader";
84 changelog = "https://github.com/coldsofttech/pym3u8downloader/blob/${src.tag}/CHANGELOG.md";
85 license = lib.licenses.mit;
86 maintainers = with lib.maintainers; [ ShamrockLee ];
87 };
88}