Skip to content

Commit

Permalink
Merge pull request #542 from Guovin/master
Browse files Browse the repository at this point in the history
dev
  • Loading branch information
Guovin authored Nov 11, 2024
2 parents 373384b + ef40bb1 commit 0208b44
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
3 changes: 1 addition & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ async def main(self):
else "result.log"
)
update_file(user_log_file, "output/result_new.log", copy=True)
cleanup_logging()
convert_to_m3u()
total_time = format_interval(time() - main_start_time)
print(
Expand All @@ -227,8 +228,6 @@ async def main(self):
run_service()
except asyncio.exceptions.CancelledError:
print("Update cancelled!")
finally:
cleanup_logging()

async def start(self, callback=None):
def default_callback(self, *args, **kwargs):
Expand Down
11 changes: 3 additions & 8 deletions utils/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def setup_logging():
Setup logging
"""
global handler
if not os.path.exists(constants.log_dir):
os.makedirs(constants.log_dir)
if not os.path.exists(constants.output_dir):
os.makedirs(constants.output_dir)
handler = RotatingFileHandler(constants.log_path, encoding="utf-8")
logging.basicConfig(
handlers=[handler],
Expand Down Expand Up @@ -643,12 +643,7 @@ async def process_sort_channel_list(data, ipv6=False, callback=None):
"""
Processs the sort channel list
"""
open_ipv6 = (
"ipv6" in config.ipv_type
or "all" in config.ipv_type
or "全部" in config.ipv_type
)
ipv6_proxy = None if not open_ipv6 or ipv6 else "http://www.ipv6proxy.net/go.php?u="
ipv6_proxy = None if (not config.open_ipv6 or ipv6) else constants.ipv6_proxy
ffmpeg_installed = is_ffmpeg_installed()
if config.open_ffmpeg and not ffmpeg_installed:
print("FFmpeg is not installed, using requests for sorting.")
Expand Down
6 changes: 6 additions & 0 deletions utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def open_filter_resolution(self):
def ipv_type(self):
return self.config.get("Settings", "ipv_type", fallback="全部").lower()

@property
def open_ipv6(self):
return (
"ipv6" in self.ipv_type or "all" in self.ipv_type or "全部" in self.ipv_type
)

@property
def ipv_type_prefer(self):
return [
Expand Down
6 changes: 4 additions & 2 deletions utils/constants.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os

log_dir = "output"
output_dir = "output"

log_file = "result_new.log"

log_path = os.path.join(log_dir, log_file)
log_path = os.path.join(output_dir, log_file)

url_pattern = r"((https?):\/\/)?(\[[0-9a-fA-F:]+\]|([\w-]+\.)+[\w-]+)(:[0-9]{1,5})?(\/[^\s]*)?(\$[^\s]+)?"

Expand Down Expand Up @@ -58,3 +58,5 @@
"subscribe": "订阅源",
"online_search": "关键字源",
}

ipv6_proxy = "http://www.ipv6proxy.net/go.php?u="
7 changes: 4 additions & 3 deletions utils/speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ async def get_speed_by_info(
return float("inf")
try:
if ipv6_proxy and url_is_ipv6:
url = ipv6_proxy + url
if ffmpeg:
url_speed = 0
speed = (url_info, url_speed)
elif ffmpeg:
speed = await check_stream_speed(url_info)
url_speed = speed[1] if speed != float("inf") else float("inf")
if url_speed == float("inf"):
Expand All @@ -160,7 +161,7 @@ async def get_speed_by_info(
speed[0][0] = add_url_info(speed[0][0], url_show_info)
speed = (tuple(speed[0]), speed[1])
return speed
except Exception:
except:
return float("inf")
finally:
if callback:
Expand Down

0 comments on commit 0208b44

Please sign in to comment.