Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored master branch #8

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ async def live(username: str, password: str, stream_id: str, ext: str, request:
if stream_url is not False:
stream_url = stream_url.replace(stream_url.split("/")[-1], "")
stream_url = stream_url + stream_id + "." + ext
query_param = request.query_params._dict
if query_param:
if query_param := request.query_params._dict:
for key, value in query_param.items():
stream_url += "?" + key + "=" + value
stream_url += f"?{key}={value}"
Comment on lines -110 to +112
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function live refactored with the following changes:

else:
CLIENT.remove_client()

Expand Down
11 changes: 7 additions & 4 deletions helper/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ def __init__(self):
self.clients = {}

def add_client(self, ip, port, chanel_watch):
self.clients[ip + ":" + port] = {"url": chanel_watch, "time_create": int(time.time())}
self.clients[f"{ip}:{port}"] = {
"url": chanel_watch,
"time_create": int(time.time()),
}
Comment on lines -10 to +13
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Client.add_client refactored with the following changes:


def get_client(self, ip, port):
# check if client is in the list
print(self.clients)
if ip + ":" + port not in self.clients:
if f"{ip}:{port}" not in self.clients:
return False
# update time_create
self.clients[ip + ":" + port]["time_create"] = int(time.time())
return self.clients[ip + ":" + port]["url"]
self.clients[f"{ip}:{port}"]["time_create"] = int(time.time())
return self.clients[f"{ip}:{port}"]["url"]
Comment on lines -15 to +22
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Client.get_client refactored with the following changes:


def remove_client(self):
current_time = int(time.time())
Expand Down
5 changes: 1 addition & 4 deletions helper/iptv.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,7 @@ def get_channel_url(self, stream_id):
channel = (
qb.select("iptv_channels").where([["stream_id", "=", stream_id]]).one()
)
if channel is None:
return None

return channel["direct_source"]
return None if channel is None else channel["direct_source"]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function M3U_Parser.get_channel_url refactored with the following changes:



class EPG_Parser:
Expand Down