xaque8787 / m3uparser Goto Github PK
View Code? Open in Web Editor NEWParse your m3u VOD list and make a .strm library for media server
Parse your m3u VOD list and make a .strm library for media server
Where is the source code?
Hi,
I have an issue with parsing my file
Processing line: #EXTINF:-1 tvg-id="#.No.Channel.#" tvg-name="✺ FR ⋆ GENERALE FHD ✺" tvg-logo="http://lg.mygolden.xyz:8080/logo/EUROPE/FRANCE/flag_france.png" group-title="FR ❖ GENERALE",✺ FR ⋆ GENERALE FHD ✺
Processing line: http://maxprime.xyz:80/Y27P36K66B57Z3/B2MR6VBCL5L7HQNJ/2586
Traceback (most recent call last):
File "/usr/src/app/parser.py", line 115, in
with open(filepath, "w") as f:
NameError: name 'filepath' is not defined
Could you suggest what could be the issue?
BR
Cris
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.
I tried to implement it in the codebase, but I still don't really understand how the current code works.
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"
}
Originally posted by @albinmedoc in #2 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.