StreamingCommunity 1.7.6__py3-none-any.whl → 1.9.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of StreamingCommunity might be problematic. Click here for more details.

Files changed (101) hide show
  1. StreamingCommunity/{Src/Api → Api}/Player/Helper/Vixcloud/js_parser.py +4 -1
  2. StreamingCommunity/{Src/Api → Api}/Player/Helper/Vixcloud/util.py +166 -166
  3. StreamingCommunity/{Src/Api → Api}/Player/ddl.py +89 -89
  4. StreamingCommunity/{Src/Api → Api}/Player/maxstream.py +151 -151
  5. StreamingCommunity/{Src/Api → Api}/Player/supervideo.py +193 -193
  6. StreamingCommunity/{Src/Api → Api}/Player/vixcloud.py +224 -212
  7. StreamingCommunity/{Src/Api → Api}/Site/1337xx/__init__.py +50 -50
  8. StreamingCommunity/{Src/Api → Api}/Site/1337xx/costant.py +15 -15
  9. StreamingCommunity/{Src/Api → Api}/Site/1337xx/site.py +83 -83
  10. StreamingCommunity/{Src/Api → Api}/Site/1337xx/title.py +66 -66
  11. StreamingCommunity/{Src/Api → Api}/Site/altadefinizione/__init__.py +50 -50
  12. StreamingCommunity/{Src/Api/Site/mostraguarda → Api/Site/altadefinizione}/costant.py +15 -15
  13. StreamingCommunity/{Src/Api → Api}/Site/altadefinizione/film.py +69 -69
  14. StreamingCommunity/{Src/Api → Api}/Site/altadefinizione/site.py +86 -86
  15. StreamingCommunity/{Src/Api → Api}/Site/animeunity/__init__.py +50 -50
  16. StreamingCommunity/{Src/Api/Site/altadefinizione → Api/Site/animeunity}/costant.py +15 -15
  17. StreamingCommunity/{Src/Api → Api}/Site/animeunity/film_serie.py +130 -131
  18. StreamingCommunity/{Src/Api → Api}/Site/animeunity/site.py +164 -164
  19. StreamingCommunity/{Src/Api → Api}/Site/animeunity/util/ScrapeSerie.py +3 -3
  20. StreamingCommunity/{Src/Api → Api}/Site/bitsearch/__init__.py +51 -51
  21. StreamingCommunity/{Src/Api → Api}/Site/bitsearch/costant.py +15 -15
  22. StreamingCommunity/{Src/Api → Api}/Site/bitsearch/site.py +84 -84
  23. StreamingCommunity/{Src/Api → Api}/Site/bitsearch/title.py +47 -47
  24. StreamingCommunity/{Src/Api → Api}/Site/cb01new/__init__.py +51 -51
  25. StreamingCommunity/{Src/Api → Api}/Site/cb01new/costant.py +15 -15
  26. StreamingCommunity/{Src/Api → Api}/Site/cb01new/film.py +69 -69
  27. StreamingCommunity/{Src/Api → Api}/Site/cb01new/site.py +74 -74
  28. StreamingCommunity/{Src/Api → Api}/Site/ddlstreamitaly/__init__.py +57 -57
  29. StreamingCommunity/{Src/Api → Api}/Site/ddlstreamitaly/costant.py +16 -16
  30. StreamingCommunity/{Src/Api → Api}/Site/ddlstreamitaly/series.py +141 -142
  31. StreamingCommunity/{Src/Api → Api}/Site/ddlstreamitaly/site.py +92 -92
  32. StreamingCommunity/{Src/Api → Api}/Site/ddlstreamitaly/util/ScrapeSerie.py +84 -82
  33. StreamingCommunity/{Src/Api → Api}/Site/guardaserie/__init__.py +52 -52
  34. StreamingCommunity/{Src/Api/Site/piratebays → Api/Site/guardaserie}/costant.py +15 -15
  35. StreamingCommunity/{Src/Api → Api}/Site/guardaserie/series.py +195 -195
  36. StreamingCommunity/{Src/Api → Api}/Site/guardaserie/site.py +84 -84
  37. StreamingCommunity/{Src/Api → Api}/Site/guardaserie/util/ScrapeSerie.py +110 -110
  38. StreamingCommunity/{Src/Api → Api}/Site/mostraguarda/__init__.py +48 -48
  39. StreamingCommunity/{Src/Api/Site/animeunity → Api/Site/mostraguarda}/costant.py +15 -15
  40. StreamingCommunity/{Src/Api → Api}/Site/mostraguarda/film.py +94 -94
  41. StreamingCommunity/{Src/Api → Api}/Site/piratebays/__init__.py +50 -50
  42. StreamingCommunity/{Src/Api/Site/guardaserie → Api/Site/piratebays}/costant.py +15 -15
  43. StreamingCommunity/{Src/Api → Api}/Site/piratebays/site.py +88 -88
  44. StreamingCommunity/{Src/Api → Api}/Site/piratebays/title.py +45 -45
  45. StreamingCommunity/{Src/Api → Api}/Site/streamingcommunity/__init__.py +55 -55
  46. StreamingCommunity/{Src/Api → Api}/Site/streamingcommunity/costant.py +15 -15
  47. StreamingCommunity/{Src/Api → Api}/Site/streamingcommunity/film.py +70 -70
  48. StreamingCommunity/{Src/Api → Api}/Site/streamingcommunity/series.py +205 -203
  49. StreamingCommunity/{Src/Api → Api}/Site/streamingcommunity/site.py +125 -125
  50. StreamingCommunity/{Src/Api → Api}/Site/streamingcommunity/util/ScrapeSerie.py +3 -3
  51. StreamingCommunity/{Src/Api → Api}/Template/Class/SearchType.py +101 -101
  52. StreamingCommunity/{Src/Api → Api}/Template/Util/__init__.py +4 -4
  53. StreamingCommunity/{Src/Api → Api}/Template/Util/get_domain.py +137 -137
  54. StreamingCommunity/{Src/Api → Api}/Template/Util/manage_ep.py +153 -153
  55. StreamingCommunity/{Src/Api → Api}/Template/Util/recall_search.py +37 -37
  56. StreamingCommunity/Api/Template/__init__.py +3 -0
  57. StreamingCommunity/{Src/Api → Api}/Template/site.py +87 -87
  58. StreamingCommunity/{Src/Lib → Lib}/Downloader/HLS/downloader.py +968 -968
  59. StreamingCommunity/{Src/Lib → Lib}/Downloader/HLS/proxyes.py +110 -110
  60. StreamingCommunity/{Src/Lib → Lib}/Downloader/HLS/segments.py +538 -540
  61. StreamingCommunity/{Src/Lib → Lib}/Downloader/MP4/downloader.py +156 -156
  62. StreamingCommunity/{Src/Lib → Lib}/Downloader/TOR/downloader.py +222 -222
  63. StreamingCommunity/{Src/Lib → Lib}/Downloader/__init__.py +4 -4
  64. StreamingCommunity/{Src/Lib → Lib}/Driver/driver_1.py +76 -76
  65. StreamingCommunity/{Src/Lib → Lib}/FFmpeg/__init__.py +4 -4
  66. StreamingCommunity/{Src/Lib → Lib}/FFmpeg/capture.py +170 -170
  67. StreamingCommunity/{Src/Lib → Lib}/FFmpeg/command.py +292 -292
  68. StreamingCommunity/{Src/Lib → Lib}/FFmpeg/util.py +241 -241
  69. StreamingCommunity/{Src/Lib → Lib}/M3U8/__init__.py +5 -5
  70. StreamingCommunity/{Src/Lib → Lib}/M3U8/decryptor.py +164 -129
  71. StreamingCommunity/{Src/Lib → Lib}/M3U8/estimator.py +175 -172
  72. StreamingCommunity/{Src/Lib → Lib}/M3U8/parser.py +666 -666
  73. StreamingCommunity/{Src/Lib → Lib}/M3U8/url_fixer.py +51 -51
  74. StreamingCommunity/Lib/TMBD/__init__.py +2 -0
  75. StreamingCommunity/{Src/Lib → Lib}/TMBD/obj_tmbd.py +39 -39
  76. StreamingCommunity/{Src/Lib → Lib}/TMBD/tmdb.py +345 -345
  77. StreamingCommunity/{Src/Upload → Upload}/update.py +68 -64
  78. StreamingCommunity/{Src/Upload → Upload}/version.py +5 -5
  79. StreamingCommunity/{Src/Util → Util}/_jsonConfig.py +204 -204
  80. StreamingCommunity/{Src/Util → Util}/call_stack.py +42 -42
  81. StreamingCommunity/{Src/Util → Util}/color.py +20 -20
  82. StreamingCommunity/{Src/Util → Util}/console.py +12 -12
  83. StreamingCommunity/Util/ffmpeg_installer.py +275 -0
  84. StreamingCommunity/{Src/Util → Util}/headers.py +147 -147
  85. StreamingCommunity/{Src/Util → Util}/logger.py +53 -53
  86. StreamingCommunity/{Src/Util → Util}/message.py +46 -46
  87. StreamingCommunity/{Src/Util → Util}/os.py +514 -417
  88. StreamingCommunity/{Src/Util → Util}/table.py +163 -163
  89. StreamingCommunity/run.py +202 -196
  90. {StreamingCommunity-1.7.6.dist-info → StreamingCommunity-1.9.1.dist-info}/METADATA +126 -60
  91. StreamingCommunity-1.9.1.dist-info/RECORD +95 -0
  92. {StreamingCommunity-1.7.6.dist-info → StreamingCommunity-1.9.1.dist-info}/WHEEL +1 -1
  93. StreamingCommunity/Src/Api/Site/animeunity/anime.py +0 -126
  94. StreamingCommunity/Src/Api/Site/ddlstreamitaly/Player/ScrapeSerie.py +0 -83
  95. StreamingCommunity/Src/Api/Site/guardaserie/Player/ScrapeSerie.py +0 -110
  96. StreamingCommunity/Src/Api/Template/__init__.py +0 -3
  97. StreamingCommunity/Src/Lib/TMBD/__init__.py +0 -2
  98. StreamingCommunity-1.7.6.dist-info/RECORD +0 -97
  99. {StreamingCommunity-1.7.6.dist-info → StreamingCommunity-1.9.1.dist-info}/LICENSE +0 -0
  100. {StreamingCommunity-1.7.6.dist-info → StreamingCommunity-1.9.1.dist-info}/entry_points.txt +0 -0
  101. {StreamingCommunity-1.7.6.dist-info → StreamingCommunity-1.9.1.dist-info}/top_level.txt +0 -0
@@ -136,5 +136,8 @@ class JavaScriptParser:
136
136
  else:
137
137
  result[var_name] = cls.parse_value(value)
138
138
 
139
+ can_play_fhd_match = re.search(r'window\.canPlayFHD\s*=\s*(\w+);?', js_string)
140
+ if can_play_fhd_match:
141
+ result['canPlayFHD'] = cls.parse_value(can_play_fhd_match.group(1))
142
+
139
143
  return result
140
-
@@ -1,166 +1,166 @@
1
- # 23.11.24
2
-
3
- import re
4
- import logging
5
- from typing import Dict, Any, List, Union
6
-
7
-
8
- class Episode:
9
- def __init__(self, data: Dict[str, Any]):
10
- self.id: int = data.get('id', '')
11
- self.number: int = data.get('number', '')
12
- self.name: str = data.get('name', '')
13
- self.plot: str = data.get('plot', '')
14
- self.duration: int = data.get('duration', '')
15
-
16
- def __str__(self):
17
- return f"Episode(id={self.id}, number={self.number}, name='{self.name}', plot='{self.plot}', duration={self.duration} sec)"
18
-
19
- class EpisodeManager:
20
- def __init__(self):
21
- self.episodes: List[Episode] = []
22
-
23
- def add_episode(self, episode_data: Dict[str, Any]):
24
- """
25
- Add a new episode to the manager.
26
-
27
- Parameters:
28
- - episode_data (Dict[str, Any]): A dictionary containing data for the new episode.
29
- """
30
- episode = Episode(episode_data)
31
- self.episodes.append(episode)
32
-
33
- def get_length(self) -> int:
34
- """
35
- Get the number of episodes in the manager.
36
-
37
- Returns:
38
- int: Number of episodes.
39
- """
40
- return len(self.episodes)
41
-
42
- def clear(self) -> None:
43
- """
44
- This method clears the episodes list.
45
-
46
- Parameters:
47
- - self: The object instance.
48
- """
49
- self.episodes.clear()
50
-
51
- def __str__(self):
52
- return f"EpisodeManager(num_episodes={len(self.episodes)})"
53
-
54
-
55
- class Season:
56
- def __init__(self, season_data: Dict[str, Union[int, str, None]]):
57
- self.id: int = season_data.get('id')
58
- self.number: int = season_data.get('number')
59
- self.name: str = season_data.get('name')
60
- self.plot: str = season_data.get('plot')
61
- self.episodes_count: int = season_data.get('episodes_count')
62
-
63
- def __str__(self):
64
- return f"Season(id={self.id}, number={self.number}, name='{self.name}', plot='{self.plot}', episodes_count={self.episodes_count})"
65
-
66
- class SeasonManager:
67
- def __init__(self):
68
- self.seasons: List[Season] = []
69
-
70
- def add_season(self, season_data: Dict[str, Union[int, str, None]]):
71
- """
72
- Add a new season to the manager.
73
-
74
- Parameters:
75
- season_data (Dict[str, Union[int, str, None]]): A dictionary containing data for the new season.
76
- """
77
- season = Season(season_data)
78
- self.seasons.append(season)
79
-
80
- def get(self, index: int) -> Season:
81
- """
82
- Get a season item from the list by index.
83
-
84
- Parameters:
85
- index (int): The index of the seasons item to retrieve.
86
-
87
- Returns:
88
- Season: The media item at the specified index.
89
- """
90
- return self.media_list[index]
91
-
92
- def get_length(self) -> int:
93
- """
94
- Get the number of seasons in the manager.
95
-
96
- Returns:
97
- int: Number of seasons.
98
- """
99
- return len(self.seasons)
100
-
101
- def clear(self) -> None:
102
- """
103
- This method clears the seasons list.
104
-
105
- Parameters:
106
- self: The object instance.
107
- """
108
- self.seasons.clear()
109
-
110
- def __str__(self):
111
- return f"SeasonManager(num_seasons={len(self.seasons)})"
112
-
113
-
114
- class Stream:
115
- def __init__(self, name: str, url: str, active: bool):
116
- self.name = name
117
- self.url = url
118
- self.active = active
119
-
120
- def __repr__(self):
121
- return f"Stream(name={self.name!r}, url={self.url!r}, active={self.active!r})"
122
-
123
- class StreamsCollection:
124
- def __init__(self, streams: list):
125
- self.streams = [Stream(**stream) for stream in streams]
126
-
127
- def __repr__(self):
128
- return f"StreamsCollection(streams={self.streams})"
129
-
130
- def add_stream(self, name: str, url: str, active: bool):
131
- self.streams.append(Stream(name, url, active))
132
-
133
- def get_streams(self):
134
- return self.streams
135
-
136
-
137
- class WindowVideo:
138
- def __init__(self, data: Dict[str, Any]):
139
- self.data = data
140
- self.id: int = data.get('id', '')
141
- self.name: str = data.get('name', '')
142
- self.filename: str = data.get('filename', '')
143
- self.size: str = data.get('size', '')
144
- self.quality: str = data.get('quality', '')
145
- self.duration: str = data.get('duration', '')
146
- self.views: int = data.get('views', '')
147
- self.is_viewable: bool = data.get('is_viewable', '')
148
- self.status: str = data.get('status', '')
149
- self.fps: float = data.get('fps', '')
150
- self.legacy: bool = data.get('legacy', '')
151
- self.folder_id: int = data.get('folder_id', '')
152
- self.created_at_diff: str = data.get('created_at_diff', '')
153
-
154
- def __str__(self):
155
- return f"WindowVideo(id={self.id}, name='{self.name}', filename='{self.filename}', size='{self.size}', quality='{self.quality}', duration='{self.duration}', views={self.views}, is_viewable={self.is_viewable}, status='{self.status}', fps={self.fps}, legacy={self.legacy}, folder_id={self.folder_id}, created_at_diff='{self.created_at_diff}')"
156
-
157
- class WindowParameter:
158
- def __init__(self, data: Dict[str, Any]):
159
- self.data = data
160
- params = data.get('params', {})
161
- self.token: str = params.get('token', '')
162
- self.expires: str = str(params.get('expires', ''))
163
- self.url = data.get('url')
164
-
165
- def __str__(self):
166
- return (f"WindowParameter(token='{self.token}', expires='{self.expires}', url='{self.url}', data={self.data})")
1
+ # 23.11.24
2
+
3
+ import re
4
+ import logging
5
+ from typing import Dict, Any, List, Union
6
+
7
+
8
+ class Episode:
9
+ def __init__(self, data: Dict[str, Any]):
10
+ self.id: int = data.get('id', '')
11
+ self.number: int = data.get('number', '')
12
+ self.name: str = data.get('name', '')
13
+ self.plot: str = data.get('plot', '')
14
+ self.duration: int = data.get('duration', '')
15
+
16
+ def __str__(self):
17
+ return f"Episode(id={self.id}, number={self.number}, name='{self.name}', plot='{self.plot}', duration={self.duration} sec)"
18
+
19
+ class EpisodeManager:
20
+ def __init__(self):
21
+ self.episodes: List[Episode] = []
22
+
23
+ def add_episode(self, episode_data: Dict[str, Any]):
24
+ """
25
+ Add a new episode to the manager.
26
+
27
+ Parameters:
28
+ - episode_data (Dict[str, Any]): A dictionary containing data for the new episode.
29
+ """
30
+ episode = Episode(episode_data)
31
+ self.episodes.append(episode)
32
+
33
+ def get_length(self) -> int:
34
+ """
35
+ Get the number of episodes in the manager.
36
+
37
+ Returns:
38
+ int: Number of episodes.
39
+ """
40
+ return len(self.episodes)
41
+
42
+ def clear(self) -> None:
43
+ """
44
+ This method clears the episodes list.
45
+
46
+ Parameters:
47
+ - self: The object instance.
48
+ """
49
+ self.episodes.clear()
50
+
51
+ def __str__(self):
52
+ return f"EpisodeManager(num_episodes={len(self.episodes)})"
53
+
54
+
55
+ class Season:
56
+ def __init__(self, season_data: Dict[str, Union[int, str, None]]):
57
+ self.id: int = season_data.get('id')
58
+ self.number: int = season_data.get('number')
59
+ self.name: str = season_data.get('name')
60
+ self.plot: str = season_data.get('plot')
61
+ self.episodes_count: int = season_data.get('episodes_count')
62
+
63
+ def __str__(self):
64
+ return f"Season(id={self.id}, number={self.number}, name='{self.name}', plot='{self.plot}', episodes_count={self.episodes_count})"
65
+
66
+ class SeasonManager:
67
+ def __init__(self):
68
+ self.seasons: List[Season] = []
69
+
70
+ def add_season(self, season_data: Dict[str, Union[int, str, None]]):
71
+ """
72
+ Add a new season to the manager.
73
+
74
+ Parameters:
75
+ season_data (Dict[str, Union[int, str, None]]): A dictionary containing data for the new season.
76
+ """
77
+ season = Season(season_data)
78
+ self.seasons.append(season)
79
+
80
+ def get(self, index: int) -> Season:
81
+ """
82
+ Get a season item from the list by index.
83
+
84
+ Parameters:
85
+ index (int): The index of the seasons item to retrieve.
86
+
87
+ Returns:
88
+ Season: The media item at the specified index.
89
+ """
90
+ return self.media_list[index]
91
+
92
+ def get_length(self) -> int:
93
+ """
94
+ Get the number of seasons in the manager.
95
+
96
+ Returns:
97
+ int: Number of seasons.
98
+ """
99
+ return len(self.seasons)
100
+
101
+ def clear(self) -> None:
102
+ """
103
+ This method clears the seasons list.
104
+
105
+ Parameters:
106
+ self: The object instance.
107
+ """
108
+ self.seasons.clear()
109
+
110
+ def __str__(self):
111
+ return f"SeasonManager(num_seasons={len(self.seasons)})"
112
+
113
+
114
+ class Stream:
115
+ def __init__(self, name: str, url: str, active: bool):
116
+ self.name = name
117
+ self.url = url
118
+ self.active = active
119
+
120
+ def __repr__(self):
121
+ return f"Stream(name={self.name!r}, url={self.url!r}, active={self.active!r})"
122
+
123
+ class StreamsCollection:
124
+ def __init__(self, streams: list):
125
+ self.streams = [Stream(**stream) for stream in streams]
126
+
127
+ def __repr__(self):
128
+ return f"StreamsCollection(streams={self.streams})"
129
+
130
+ def add_stream(self, name: str, url: str, active: bool):
131
+ self.streams.append(Stream(name, url, active))
132
+
133
+ def get_streams(self):
134
+ return self.streams
135
+
136
+
137
+ class WindowVideo:
138
+ def __init__(self, data: Dict[str, Any]):
139
+ self.data = data
140
+ self.id: int = data.get('id', '')
141
+ self.name: str = data.get('name', '')
142
+ self.filename: str = data.get('filename', '')
143
+ self.size: str = data.get('size', '')
144
+ self.quality: str = data.get('quality', '')
145
+ self.duration: str = data.get('duration', '')
146
+ self.views: int = data.get('views', '')
147
+ self.is_viewable: bool = data.get('is_viewable', '')
148
+ self.status: str = data.get('status', '')
149
+ self.fps: float = data.get('fps', '')
150
+ self.legacy: bool = data.get('legacy', '')
151
+ self.folder_id: int = data.get('folder_id', '')
152
+ self.created_at_diff: str = data.get('created_at_diff', '')
153
+
154
+ def __str__(self):
155
+ return f"WindowVideo(id={self.id}, name='{self.name}', filename='{self.filename}', size='{self.size}', quality='{self.quality}', duration='{self.duration}', views={self.views}, is_viewable={self.is_viewable}, status='{self.status}', fps={self.fps}, legacy={self.legacy}, folder_id={self.folder_id}, created_at_diff='{self.created_at_diff}')"
156
+
157
+ class WindowParameter:
158
+ def __init__(self, data: Dict[str, Any]):
159
+ self.data = data
160
+ params = data.get('params', {})
161
+ self.token: str = params.get('token', '')
162
+ self.expires: str = str(params.get('expires', ''))
163
+ self.url = data.get('url')
164
+
165
+ def __str__(self):
166
+ return (f"WindowParameter(token='{self.token}', expires='{self.expires}', url='{self.url}', data={self.data})")
@@ -1,89 +1,89 @@
1
- # 14.06.24
2
-
3
- import logging
4
-
5
-
6
- # External libraries
7
- import httpx
8
- from bs4 import BeautifulSoup
9
-
10
-
11
- # Internal utilities
12
- from StreamingCommunity.Src.Util._jsonConfig import config_manager
13
- from StreamingCommunity.Src.Util.headers import get_headers
14
-
15
-
16
- # Variable
17
- from StreamingCommunity.Src.Api.Site.ddlstreamitaly.costant import COOKIE
18
- max_timeout = config_manager.get_int("REQUESTS", "timeout")
19
-
20
-
21
- class VideoSource:
22
- def __init__(self) -> None:
23
- """
24
- Initializes the VideoSource object with default values.
25
- """
26
- self.headers = {'user-agent': get_headers()}
27
- self.cookie = COOKIE
28
-
29
- def setup(self, url: str) -> None:
30
- """
31
- Sets up the video source with the provided URL.
32
-
33
- Parameters:
34
- - url (str): The URL of the video source.
35
- """
36
- self.url = url
37
-
38
- def make_request(self, url: str) -> str:
39
- """
40
- Make an HTTP GET request to the provided URL.
41
-
42
- Parameters:
43
- - url (str): The URL to make the request to.
44
-
45
- Returns:
46
- - str: The response content if successful, None otherwise.
47
- """
48
- try:
49
- response = httpx.get(
50
- url=url,
51
- headers=self.headers,
52
- cookies=self.cookie,
53
- timeout=max_timeout
54
- )
55
- response.raise_for_status()
56
-
57
- return response.text
58
-
59
- except Exception as err:
60
- logging.error(f"An error occurred: {err}")
61
-
62
- return None
63
-
64
- def get_playlist(self):
65
- """
66
- Retrieves the playlist URL from the video source.
67
-
68
- Returns:
69
- - tuple: The mp4 link if found, None otherwise.
70
- """
71
- try:
72
- text = self.make_request(self.url)
73
-
74
- if text:
75
- soup = BeautifulSoup(text, "html.parser")
76
- source = soup.find("source")
77
-
78
- if source:
79
- mp4_link = source.get("src")
80
- return mp4_link
81
-
82
- else:
83
- logging.error("No <source> tag found in the HTML.")
84
-
85
- else:
86
- logging.error("Failed to retrieve content from the URL.")
87
-
88
- except Exception as e:
89
- logging.error(f"An error occurred while parsing the playlist: {e}")
1
+ # 14.06.24
2
+
3
+ import logging
4
+
5
+
6
+ # External libraries
7
+ import httpx
8
+ from bs4 import BeautifulSoup
9
+
10
+
11
+ # Internal utilities
12
+ from StreamingCommunity.Util._jsonConfig import config_manager
13
+ from StreamingCommunity.Util.headers import get_headers
14
+
15
+
16
+ # Variable
17
+ from StreamingCommunity.Api.Site.ddlstreamitaly.costant import COOKIE
18
+ max_timeout = config_manager.get_int("REQUESTS", "timeout")
19
+
20
+
21
+ class VideoSource:
22
+ def __init__(self) -> None:
23
+ """
24
+ Initializes the VideoSource object with default values.
25
+ """
26
+ self.headers = {'user-agent': get_headers()}
27
+ self.cookie = COOKIE
28
+
29
+ def setup(self, url: str) -> None:
30
+ """
31
+ Sets up the video source with the provided URL.
32
+
33
+ Parameters:
34
+ - url (str): The URL of the video source.
35
+ """
36
+ self.url = url
37
+
38
+ def make_request(self, url: str) -> str:
39
+ """
40
+ Make an HTTP GET request to the provided URL.
41
+
42
+ Parameters:
43
+ - url (str): The URL to make the request to.
44
+
45
+ Returns:
46
+ - str: The response content if successful, None otherwise.
47
+ """
48
+ try:
49
+ response = httpx.get(
50
+ url=url,
51
+ headers=self.headers,
52
+ cookies=self.cookie,
53
+ timeout=max_timeout
54
+ )
55
+ response.raise_for_status()
56
+
57
+ return response.text
58
+
59
+ except Exception as err:
60
+ logging.error(f"An error occurred: {err}")
61
+
62
+ return None
63
+
64
+ def get_playlist(self):
65
+ """
66
+ Retrieves the playlist URL from the video source.
67
+
68
+ Returns:
69
+ - tuple: The mp4 link if found, None otherwise.
70
+ """
71
+ try:
72
+ text = self.make_request(self.url)
73
+
74
+ if text:
75
+ soup = BeautifulSoup(text, "html.parser")
76
+ source = soup.find("source")
77
+
78
+ if source:
79
+ mp4_link = source.get("src")
80
+ return mp4_link
81
+
82
+ else:
83
+ logging.error("No <source> tag found in the HTML.")
84
+
85
+ else:
86
+ logging.error("Failed to retrieve content from the URL.")
87
+
88
+ except Exception as e:
89
+ logging.error(f"An error occurred while parsing the playlist: {e}")