-
Notifications
You must be signed in to change notification settings - Fork 0
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
Source code #2
Comments
It is available now. My apologies, still learning how to properly use git. Future updates should be done in the proper manner with commits, PR and merge, and all that jazz. Currently redoing the parser script to properly handle varying m3u formats, which should then support m3us from more providers. |
I ran into problems running the code, and I seem to understand why. In current code, tvgroup is assumed to be the first attribute, but this is not always the case. A slightly "kinder" way of retrieving the attribute would be needed. Wrote up a quick function that can be used to support various m3u formats. Hopefully this can help you. import re
def extract_key_value_pairs(s):
# Define the regular expression pattern
pattern = r'(\w+(?:-\w+)?)="([^"]*)"'
# Find all matches in the string
matches = re.findall(pattern, s)
# Create a dictionary from the matches
result = {key: value for key, value in matches}
return result
# Example input string
input_string = '#EXTINF:0 channelID="x-ID.0" tvg-chno="1000" tvg-name="Apan [SE] [2009]" tvg-id="1000" tvg-logo="https://image.tmdb.org/t/p/w600_and_h900_bestv2/bZcK8blLUXjMv2u0Kh7GDl9kT2I.jpg" group-title="VOD: Svenska",Apan [SE] [2009]'
# Extract key-value pairs
result_dict = extract_key_value_pairs(input_string)
# Print the full dict
print(result_dict)
# Print a specific key
print(result_dict["group-title"]) The function returns a dict representing all attributes. {
"channelID":"x-ID.0",
"tvg-chno":"1000",
"tvg-name":"Apan [SE] [2009]",
"tvg-id":"1000",
"tvg-logo":"https://image.tmdb.org/t/p/w600_and_h900_bestv2/bZcK8blLUXjMv2u0Kh7GDl9kT2I.jpg",
"group-title":"VOD: Svenska"
} |
Where is the source code?
The text was updated successfully, but these errors were encountered: