Skip to content

Commit

Permalink
Merge pull request #737 from Guovin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Guovin authored Dec 25, 2024
2 parents b9c3613 + 9d63f16 commit 589cc28
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
15 changes: 10 additions & 5 deletions service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys

sys.path.append(os.path.dirname(sys.path[0]))
from flask import Flask, render_template_string
from flask import Flask, send_from_directory, make_response
from utils.tools import get_result_file_content, get_ip_address, resource_path
from utils.config import config
import utils.constants as constants
Expand All @@ -15,6 +15,12 @@ def show_index():
return get_result_file_content()


@app.route("/favicon.ico")
def favicon():
return send_from_directory(resource_path('static/images'), 'favicon.ico',
mimetype='image/vnd.microsoft.icon')


@app.route("/txt")
def show_txt():
return get_result_file_content(file_type="txt")
Expand All @@ -38,10 +44,9 @@ def show_log():
content = file.read()
else:
content = constants.waiting_tip
return render_template_string(
"<head><link rel='icon' href='{{ url_for('static', filename='images/favicon.ico') }}' type='image/x-icon'></head><pre>{{ content }}</pre>",
content=content,
)
response = make_response(content)
response.mimetype = "text/plain"
return response


def run_service():
Expand Down
1 change: 1 addition & 0 deletions utils/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ def write_channel_to_file(data, ipv6=False, callback=None):
)
write_content_into_txt(f"🕘️更新时间,#genre#", path, newline=False)
write_content_into_txt(f"{update_time},{update_time_url}", path)
write_content_into_txt("", path)
for cate, channel_obj in data.items():
print(f"\n{cate}:", end=" ")
write_content_into_txt(f"{cate},#genre#", path)
Expand Down
10 changes: 5 additions & 5 deletions utils/speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ async def get_speed_with_download(url: str, session: ClientSession = None, timeo
async for chunk in response.content.iter_any():
if chunk:
total_size += len(chunk)
except Exception as e:
except:
pass
finally:
end_time = time()
total_time += end_time - start_time
info['speed'] = (total_size / total_time if total_time > 0 else 0) / 1024 / 1024
if total_size > 0:
total_time += time() - start_time
info['speed'] = ((total_size / total_time) if total_time > 0 else 0) / 1024 / 1024
if created_session:
await session.close()
return info
Expand Down Expand Up @@ -127,7 +127,7 @@ async def get_speed_m3u8(url: str, filter_resolution: bool = config.open_filter_
except:
pass
finally:
if filter_resolution:
if filter_resolution and info['delay'] is not None:
info['resolution'] = await get_resolution_ffprobe(url, timeout)
return info

Expand Down
9 changes: 4 additions & 5 deletions utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import requests
from bs4 import BeautifulSoup
from flask import render_template_string, send_file
from flask import send_file, make_response

import utils.constants as constants
from utils.config import config
Expand Down Expand Up @@ -406,10 +406,9 @@ def get_result_file_content(show_content=False, file_type=None):
content = file.read()
else:
content = constants.waiting_tip
return render_template_string(
"<head><link rel='icon' href='{{ url_for('static', filename='images/favicon.ico') }}' type='image/x-icon'></head><pre>{{ content }}</pre>",
content=content,
)
response = make_response(content)
response.mimetype = 'text/plain'
return response


def remove_duplicates_from_tuple_list(tuple_list, seen, flag=None, force_str=None):
Expand Down

0 comments on commit 589cc28

Please sign in to comment.