Assistant: 
User: System: Lütfen aşağıdaki metni özetleyin.
User: Merhaba.
User: https://github.com/keyiflerolsun/IPTV_YenirMi/tree/main/m3u_parser
User: 




























































































IPTV_YenirMi/m3u_parser at main · keyiflerolsun/IPTV_YenirMi · GitHub













































Skip to content













Navigation Menu

Toggle navigation




 













            Sign in
          








        Product
        













GitHub Copilot
        Write better code with AI
      







Security
        Find and fix vulnerabilities
      







Actions
        Automate any workflow
      







Codespaces
        Instant dev environments
      







Issues
        Plan and track work
      







Code Review
        Manage code changes
      







Discussions
        Collaborate outside of code
      







Code Search
        Find more, search less
      






Explore



      All features

    



      Documentation

    





      GitHub Skills

    





      Blog

    










        Solutions
        






By size



      Enterprise

    



      Teams

    



      Startups

    




By industry



      Healthcare

    



      Financial services

    



      Manufacturing

    




By use case



      CI/CD & Automation

    



      DevOps

    



      DevSecOps

    








        Resources
        






Topics



      AI

    



      DevOps

    



      Security

    



      Software Development

    



      View all

    






Explore



      Learning Pathways

    





      White papers, Ebooks, Webinars

    





      Customer Stories

    



      Partners

    










        Open Source
        










GitHub Sponsors
        Fund open source developers
      








The ReadME Project
        GitHub community articles
      




Repositories



      Topics

    



      Trending

    



      Collections

    








        Enterprise
        













Enterprise platform
        AI-powered developer platform
      




Available add-ons







Advanced Security
        Enterprise-grade security features
      







GitHub Copilot
        Enterprise-grade AI features
      







Premium Support
        Enterprise-grade 24/7 support
      







Pricing












Search or jump to...







Search code, repositories, users, issues, pull requests...

 




        Search
      













Clear
 
















































 




              Search syntax tips
 














        Provide feedback
      









 
We read every piece of feedback, and take your input very seriously.


Include my email address so I can be contacted


     Cancel

    Submit feedback










        Saved searches
      
Use saved searches to filter your results more quickly









 





Name






Query



            To see all available qualifiers, see our documentation.
          
 





     Cancel

    Create saved search








                Sign in
              


                Sign up
              
Reseting focus









You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.
You switched accounts on another tab or window. Reload to refresh your session.
 


Dismiss alert



















        keyiflerolsun
 
/

IPTV_YenirMi

Public








 

Notifications
 You must be signed in to change notification settings


 

Fork
    12




 


          Star
 50














Code







Issues
2






Pull requests
0






Actions







Security







Insights



 

 


Additional navigation options


 










          Code











          Issues











          Pull requests











          Actions











          Security











          Insights






 







   Files mainBreadcrumbsIPTV_YenirMi/m3u_parser/Directory actionsMore optionsDirectory actionsMore optionsLatest commit HistoryHistory mainBreadcrumbsIPTV_YenirMi/m3u_parser/TopFolders and filesNameNameLast commit messageLast commit dateparent directory..README.mdREADME.md  __init__.py__init__.py  helper.pyhelper.py  m3u_parser.pym3u_parser.py  View all filesREADME.mdWelcome to m3u_parser




A parser for m3u files.
It parses the contents of m3u file to a list of streams information which can be saved as a JSON/CSV file.



Check go-m3u-parser and ts-m3u-parser also.


🏠 Homepage
Install

pip install m3u-parser

OR

pipenv install m3u-parser

Example
from m3u_parser import M3uParser
url = "/home/pawan/Downloads/ru.m3u"
useragent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
parser = M3uParser(timeout=5, useragent=useragent)
parser.parse_m3u(url)
parser.remove_by_extension('mp4')
parser.filter_by('status', 'GOOD')
print(len(parser.get_list()))
parser.to_file('pawan.json')
Usage
from m3u_parser import M3uParser
url = "/home/pawan/Downloads/ru.m3u"
useragent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
parser = M3uParser(timeout=5, useragent=useragent)

Functions

def parse_m3u(self, path: str, check_live: bool = True, enforce_schema: bool = False):
        """Parses the content of local file/URL.

        It downloads the file from the given url or use the local file path to get the content and parses line by line
        to a structured format of streams information.

        :param path: Path can be a url or local filepath
        :type path: str
        :param enforce_schema: If the schema is forced, non-existing fields in a stream are filled with None/null. If it is not enforced, non-existing fields are ignored
        :type enforce_schema: bool
        :param check_live: To check if the stream links are working or not
        :type check_live: bool
        :rtype: None
        """

def filter_by(self, key: str, filters: Union[str, list], key_splitter: str = "-", retrieve: bool = True, nested_key: bool = False):
        """Filter streams infomation.

        It retrieves/removes stream information from streams information list using filter/s on key.

        :param key: Key can be single or nested. eg. key='name', key='language-name'
        :type key: str
        :param filters: List of filter/s to perform the retrieve or remove operation.
        :type filters: str or list
        :param key_splitter: A splitter to split the nested keys. Default: "-"
        :type key_splitter: str
        :param retrieve: True to retrieve and False for removing based on key.
        :type retrieve: bool
        :param nested_key: True/False for if the key is nested or not.
        :type nested_key: bool
        :rtype: None
        """

def reset_operations(self):
        """Reset the stream information list to initial state before various operations.

        :rtype: None
        """

def remove_by_extension(self, extension: Union[str, list])
        """Remove stream information with certain extension/s.

        It removes stream information from streams information list based on extension/s provided.

        :param extension: Name of the extension like mp4, m3u8 etc. It can be a string or list of extension/s.
        :type extension: str or list
        :rtype: None
        """

def retrieve_by_extension(self, extension: Union[str, list]):
        """Select only streams information with a certain extension/s.

        It retrieves the stream information based on extension/s provided.

        :param extension: Name of the extension like mp4, m3u8 etc. It can be a string or list of extension/s.
        :type extension: str or list
        :rtype: None
        """

def remove_by_category(self, filter_word: Union[str, list]):
        """Removes streams information with category containing a certain filter word/s.

        It removes stream information based on category using filter word/s.

        :param filter_word: It can be a string or list of filter word/s.
        :type filter_word: str or list
        :rtype: None
        """

def retrieve_by_category(self, filter_word: Union[str, list]):
        """Retrieve only streams information that contains a certain filter word/s.

        It retrieves stream information based on category/categories.

        :param filter_word: It can be a string or list of filter word/s.
        :type filter_word: str or list
        :rtype: None
        """

def sort_by(self, key: str, key_splitter: str = "-", asc: bool = True, nested_key: bool = False):
        """Sort streams information.

        It sorts streams information list sorting by key in asc/desc order.

        :param key: It can be single or nested key.
        :type key: str
        :param key_splitter: A splitter to split the nested keys. Default: "-"
        :type key_splitter: str
        :param asc: Sort by asc or desc order
        :type asc: bool
        :param nested_key: True/False for if the key is nested or not.
        :type nested_key: bool
        :rtype: None
        """

def get_json(self, indent: int = 4):
        """Get the streams information as json.

        :param indent: Int value for indentation.
        :type indent: int
        :return: json of the streams_info list
        :rtype: json
        """

def get_list(self):
        """Get the parsed streams information list.

        It returns the streams information list.

        :return: Streams information list
        :rtype: list
        """

def get_random_stream(self, random_shuffle: bool = True):
        """Return a random stream information

        It returns a random stream information with shuffle if required.

        :param random_shuffle: To shuffle the streams information list before returning the random stream information.
        :type random_shuffle: bool
        :return: A random stream info
        :rtype: dict
        """

def to_file(self, filename: str, format: str = "json"):
        """Save to file (CSV, JSON, or M3U)

        It saves streams information as a CSV, JSON, or M3U file with a given filename and format parameters.

        :param filename: Name of the file to save streams_info as.
        :type filename: str
        :param format: csv/json/m3u to save the streams_info.
        :type format: str
        :rtype: None
        """
Author
👤 Pawan Paudel

Github: @pawanpaudel93

🤝 Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page.
Show your support
Give a ⭐️ if this project helped you!
Copyright © 2020 Pawan Paudel.
   








Footer








        © 2024 GitHub, Inc.
      


Footer navigation


Terms


Privacy


Security


Status


Docs


Contact




      Manage cookies
    





      Do not share my personal information
    
















    You can’t perform that action at this time.
  













Assistant:
Assistant: