Jump to content


Photo

python script to convert m3u file to strm files with emby folder structure (free)

m3u strm vod iptv

  • Please log in to reply
35 replies to this topic

#21 requa3r0 OFFLINE  

requa3r0

    Newbie

  • Members
  • 9 posts
  • Local time: 02:25 PM

Posted 20 March 2020 - 10:01 AM

I have a quisiton to t1m.

 

Your script is pretty nice, so you are deffently most cable of writing code

 

Would you be intersted in making a M3u to IPTV app setup file converter.

 

To sideload the M3u into the IPTV app.

 

I have Emby Premiere, and use the M3U tuner and EPG data setup as you can with a license,  but lots dont have alicense and dont care about EPG data etc.

Its very tedious to mannualy load and maintain the IPTV app, with hundreds of TV channels.

Its a bit strange that the IPTV app does not have a bulk loader interface, to load and maintain the channels.

 

so...Could you script a M3u to MediaBrowser.Channels.IPTV.xml generator ?

 

To automatically sideload the IPTV app with automatically updated M3u links?

 

Just an idear to make Emby more versatile.

 

Requaero

 



#22 t1m OFFLINE  

t1m

    Advanced Member

  • Members
  • 35 posts
  • Local time: 08:25 AM

Posted 20 March 2020 - 08:25 PM

I have a quisiton to t1m.

 

Your script is pretty nice, so you are deffently most cable of writing code

 

Would you be intersted in making a M3u to IPTV app setup file converter.

 

To sideload the M3u into the IPTV app.

 

I have Emby Premiere, and use the M3U tuner and EPG data setup as you can with a license,  but lots dont have alicense and dont care about EPG data etc.

Its very tedious to mannualy load and maintain the IPTV app, with hundreds of TV channels.

Its a bit strange that the IPTV app does not have a bulk loader interface, to load and maintain the channels.

 

so...Could you script a M3u to MediaBrowser.Channels.IPTV.xml generator ?

 

To automatically sideload the IPTV app with automatically updated M3u links?

 

Just an idear to make Emby more versatile.

 

Requaero

Hi Requaero.

I will have to research it, but this was something I was already thinking of doing. I was planning to fork the plugin called "iptv" to allow someone to load their VOD m3u direct into this to get the VOD libraries, thereby bypassing the strm file requirement alltogether.  I'm not experienced enough with emby yet to know how to do it, and even if I use this script i'll have to port it to c# first.

I will make this my goal but it will be at least a few weeks before i finish it.  I'll keep you updated here.



#23 t1m OFFLINE  

t1m

    Advanced Member

  • Members
  • 35 posts
  • Local time: 08:25 AM

Posted 20 March 2020 - 08:32 PM

Hi Nice work

 

I did not test it yet.

 

As of now im using this webpage

 

https://iptv-tools.c...ols/m3u-to-strm

Propplerly use Name...not the tvg-name (Default)

 

This could also be a solusion for some.

 

I have emailed with the owner, and its alowed to use the API to scrpit a download of the strm.zip

 

I have recieved the API from him but needed to edit it a bit to work porpperly.

 

Here is is as a gift to all

curl -X POST -d '{"url":"http://tv..---some--link--and--login--stuff----&type=m3u_plus&output=ts","tag":"name","movies":true,"series":true}' https://tools.erdesigns.eu/strm >> /var/lib/someprogram/strm.zip

NB

 

As a bonus ill give the bash command to spilt a M3U file into each contry and VOD section

#download

wget --user-agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0" "http://tv...---some--link--and--login--stuff----&&type=m3u_plus&output=ts"-O /var/lib/somefile.m3u

#split M3U
csplit -z /var/lib/hts/.xmltv/somefilename.m3u /'tvg-name=" ^v'/ '{*}'

thenmove the propper xx01 and xx02 etc to correct lable.m3u file ass needed.

 

I found a "black bar" shown as '^v' in my linux server (shown correctly on my mac ?? ) deviding each section in the M3U file..and then it was easy to split the file up;O)

 

Investigate our own file for the devider key!

 

replace /'tvg-name=" ^v'/ with /your-key/

 

Then, just add the file header to your new files and you are good to go

    #file-header
    sed -i '1s/^/#EXTM3U\n/' /var/lib/hts/.xmltv/somefile.DK.M3U



Smack everyting into a script and run it in cron...and use them for emby and kodi etc.

 

In Emby, you can now add each M3u sectment  as a TV tuner...and asign correct EPG link to each one.

 

An you can make the strm folder/ files for the index of VOD stuff

 

Pretty handy ;O)

 

Since the world has gone crazy with corona virus, I have had a lot of extra time on my hands (as I'm sure many of you can relate) and so I've decided to start writing the plugin to accept VOD m3u url without putting them into the EPG guide but rather have a library. For me having them in their own library gives me amazing imdb/moviedb/tvdb integrations that are not possible to get in the epg guide without adding extra info into the m3u.

I found using the EPG/ tvtuner for vod caused my emby to become SUPER slow adding the guid, plus it did not seem to integrate it with tvdb and imdb correctly.  I am working on a plugin to try to make it add vod movie and vod tv libraries with just inputting a m3u url, but it is a ways out.

I did see the website you mentioned, but I was more comfortable parsing my files locally instead of trusting a third party with my streams... more though I just wanted to play around in python on it.

I have a new version of the script almost ready to relase which is much simpler for the end user to use. It uses classes and functions in order to run more efficiently, and I've made some improvements to the parser.  I guess I could also make one that uses the API you mentioned. For most users that website and/or using the api as you mention above is probably simpler than trying to use my python script.

If you want to help contribute could you give me any examples of your vod m3u section... tv and movie, just a few lines showing distinct examples, be sure to edit out your username and password and server urls.

 

Have a good day everyone.  
 



#24 t1m OFFLINE  

t1m

    Advanced Member

  • Members
  • 35 posts
  • Local time: 08:25 AM

Posted 20 March 2020 - 08:33 PM

I have a quisiton to t1m.

 

Your script is pretty nice, so you are deffently most cable of writing code

 

Would you be intersted in making a M3u to IPTV app setup file converter.

 

To sideload the M3u into the IPTV app.

 

I have Emby Premiere, and use the M3U tuner and EPG data setup as you can with a license,  but lots dont have alicense and dont care about EPG data etc.

Its very tedious to mannualy load and maintain the IPTV app, with hundreds of TV channels.

Its a bit strange that the IPTV app does not have a bulk loader interface, to load and maintain the channels.

 

so...Could you script a M3u to MediaBrowser.Channels.IPTV.xml generator ?

 

To automatically sideload the IPTV app with automatically updated M3u links?

 

Just an idear to make Emby more versatile.

 

Requaero

I should ask from what you are describing. I THINK (not sure because i haven't tried) that the plugin called "IPTV" does what you are looking for



#25 Rom1toul1 OFFLINE  

Rom1toul1

    Member

  • Members
  • 11 posts
  • Local time: 02:25 PM

Posted 21 March 2020 - 04:16 AM

Hello, So good job @t1m...

Thank you so much.

#26 t1m OFFLINE  

t1m

    Advanced Member

  • Members
  • 35 posts
  • Local time: 08:25 AM

Posted 21 March 2020 - 04:20 AM

well, I played with it for a while tonight but didn't get it finished.  I ported the m3u parser into c# and created a really simple channel plugin but I have not yet got it to add the m3u yet, just a list of individual streams... I am having trouble figuring out how to make those streams be parsed as movies or tv, I also am not sure if i can have both movies and tv series in one channel... 

I'm considering using a different method, whereby it would just be a plugin that can create the strm filesystem, but using this method I have not found how to create new libraries programatically yet.  It will take a while before I have anything ready to show the community!  Still alot of fun.



#27 requa3r0 OFFLINE  

requa3r0

    Newbie

  • Members
  • 9 posts
  • Local time: 02:25 PM

Posted 21 March 2020 - 01:11 PM

Very good news

 

A fork of the IPTV app what will allow M3u import...would be great.

As i see it. The Emby premium feature to load m3u as a tv tvtuner...to pair with EPG data...is fine...for everyone who have payed for a license.

I geuss some pro features must exist..and im good with that..i have a lifetime license.

 

But it makes no sense that every free user of empy has to sit at type in hundreds of IPTV links in the IPTV app...and maintain them as they update..just because the IPTV app does not support bulk import. This needs to be resolved.

 

But ...as a solusion first...a script that will convert a m3u to IPTV config file..to sideload the IPTV app...will most deffentliy help a lot.

 

I have no shares in this problem..but would like to see it solved anyway ;O)



#28 requa3r0 OFFLINE  

requa3r0

    Newbie

  • Members
  • 9 posts
  • Local time: 02:25 PM

Posted 21 March 2020 - 05:07 PM

Just to clear up what i mean with side load the original IPTV app.

 

It has all the tv channels saved in a config file hidden here.

/var/lib/emby/plugins/configurations/MediaBrowser.Channels.IPTV.xml
 

On a debian 9 linux anyway.

 

The trick is to parse the M3u file, or subsection heroff...with live TV channels...

NOT VOD (This is sideloaded with strm folder/files and indexed as normal based on content etc.)

 

The file structure is as follows

<?xml version="1.0"?>
<PluginConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Bookmarks>
    <Bookmark>
      <Name>DR 1 DK GEO</Name>
      <Image>https://danishbits.org/static/bitbucket/users/1514675161.6633.png</Image>
      <Path>https://dr01-lh.akamaihd.net/i/live/dr01_0@147054/master.m3u8?b=100-10000</Path>
      <Protocol>Http</Protocol>
      <UserId>***** USERID *****</UserId>
    </Bookmark>
    <Bookmark>
      <Name>DR 2 DK GEO</Name>
      <Image>https://danishbits.org/static/bitbucket/users/1514675219.3517.png</Image>
      <Path>https://dr02-lh.akamaihd.net/i/live/dr02_0@147055/master.m3u8?b=100-10000</Path>
      <Protocol>Http</Protocol>
      <UserId>***** USERID *****</UserId>
    </Bookmark>
    <Bookmark>
      <Name>DR 3 DK GEO</Name>
      <Image>https://danishbits.org/static/bitbucket/users/1514675240.2972.png</Image>
      <Path>https://dr03-lh.akamaihd.net/i/live/dr03_0@147056/master.m3u8?b=100-10000</Path>
      <Protocol>Http</Protocol>
      <UserId>***** USERID *****</UserId>
    </Bookmark>
    <Bookmark>
      <Name>DR KULTUR DK GEO</Name>
      <Image>https://danishbits.org/static/bitbucket/users/1514675260.777.png</Image>
      <Path>https://dr04-lh.akamaihd.net/i/live/dr04_0@147057/master.m3u8?b=100-10000</Path>
      <Protocol>Http</Protocol>
      <UserId>***** USERID *****</UserId>
    </Bookmark>
    <Bookmark>
      <Name>DR RAMASJANG DK GEO</Name>
      <Image>https://danishbits.org/static/bitbucket/users/1514675309.4873.png</Image>
      <Path>https://dr05-lh.akamaihd.net/i/live/dr05_0@147058/master.m3u8?b=100-10000</Path>
      <Protocol>Http</Protocol>
      <UserId>***** USERID *****</UserId>
    </Bookmark>

etc etc etc

     <Bookmark>
      <Name>Showtime</Name>
      <Image>https://danishbits.org/static/bitbucket/users/1549643055.2418.png</Image>
      <Path>http://80.80.160.168/live/7/live.m3u8</Path>
      <Protocol>Http</Protocol>
      <UserId>7e77537889044e159cc8072ac2928d88</UserId>
    </Bookmark>
    <Bookmark>
      <Name>TV3max</Name>
      <Image />
      <Path>http://192.168.1.100:9981/play/stream/service/d431a4cab1994e0c6291682b8e37090b?title=TV3%20MAX%20%2F%20YouSee</Path>
      <Protocol>Http</Protocol>
      <UserId>20fe5e5e034743f79874cca08852fc47</UserId>
    </Bookmark>
  </Bookmarks>
</PluginConfiguration>

.

.

All you need to do is parse the M3u file to this structure...overwrite the config file...and start emby

(which must be stoped duing the overwrite)

 

Done.

 

You now have live TV.. (no EPG data ) in the IPTV app

And VOD in your standard library via the strm folder/files.

 

all done

 

enjoy

 

Requaero


Edited by requa3r0, 21 March 2020 - 05:13 PM.


#29 t1m OFFLINE  

t1m

    Advanced Member

  • Members
  • 35 posts
  • Local time: 08:25 AM

Posted 21 March 2020 - 05:22 PM

Hey Requaero
Thanks for showing me that. I already am half way through making a plugin which takes the m3u url and generates the libraries. Just trying to decide if i should use a channel or do it through the filesystem with strm files.

I will add the ability to do what you are asking to add to the iptv plugin to the python script tonight.

Is there any chat rooms related to development of emby stuff? If not we should make one. Either Irc or discord

#30 requa3r0 OFFLINE  

requa3r0

    Newbie

  • Members
  • 9 posts
  • Local time: 02:25 PM

Posted 21 March 2020 - 05:30 PM

I'm not aware of any chatroom...its been years since i used irc.

Can you make the pytho script as an individual script..just to parse the M3u to IPTV xml file.

It would make it a bit more easy to work with.

 

I think i will use the mu3 tuner + epg data..for my main channels..and IPTV for extra...such as the 450 US channels etc.

 

I tried your script..but did not have any success ;O(

root@xxxxx:/var/lib/hts/.xmltv/test# ./run.py 
./run.py: line 18: 
This is a python script to parse an m3u file that has a list of VOD media, and create a folder structure like follows:
/workspace folder
  /groupname
    /title(year)
      /resolution
        title.strm
title.strm is a text file which has the URL to the stream inside of it
the strm files can then be used in your emby media server as defined here:
https://support.emby.media/support/solutions/articles/44001159147-strm-files
additional reference material here:
https://emby.media/community/index.php?/topic/674-media-files-folders-structure/
https://support.emby.media/support/solutions/articles/44001159102-movie-naming
https://support.emby.media/support/solutions/articles/44001159319-library-setup
I plan to do some more work to this at some point, but i just needed something quick n dirty.  
Change the m3u file name to the m3u file you want to use, and root directory is relative to
the working directory which the python script is executed in ...
: No such file or directory
./run.py: line 19: import: command not found
./run.py: line 21: m3ufile: command not found
./run.py: line 23: rootdirectory: command not found
./run.py: line 25: syntax error near unexpected token `('
./run.py: line 25: `m3ulist = open(m3ufile,"r")'
root@xxxxx:/var/lib/hts/.xmltv/test# 

I did set

import os
#this should be the name of your m3u and in the same directory as this python file.
m3ufile = "danishM3u.m3u"
#root directory should be created already, it is where the group folders will be located. relative to the working directory.
rootdirectory = "strms"


?



#31 requa3r0 OFFLINE  

requa3r0

    Newbie

  • Members
  • 9 posts
  • Local time: 02:25 PM

Posted 21 March 2020 - 05:34 PM

root@xxxx:/var/lib/hts/.xmltv/test# python run.py
Traceback (most recent call last):
  File "run.py", line 44, in <module>
    stream.append(info[1]) #language
IndexError: list index out of range

do i need to run it as >python run.py

 

And what is this errro



#32 t1m OFFLINE  

t1m

    Advanced Member

  • Members
  • 35 posts
  • Local time: 08:25 AM

Posted 21 March 2020 - 06:21 PM

Right now it will only parse the two types of vod m3u as i show in my first post in this thread. There are two scripts the first one does the first type and the second does the second type.
It wont parse livetv m3u just yet.

You need to run it with python3 also

#33 t1m OFFLINE  

t1m

    Advanced Member

  • Members
  • 35 posts
  • Local time: 08:25 AM

Posted 26 March 2020 - 08:57 PM

I have updated the program... it is currently located at https://github.com/s...rm/tree/nextgen

You'll need to clone the whole branch then set your m3u file name in main.py, then python3 main.py

 

This one is faster, more versitile (handles a broader range of m3u file types) and, has parsing support for live tv streams (though it does not generate the stream files for live streams)

try it out, let me know what you think.



#34 MaMoUs OFFLINE  

MaMoUs

    Member

  • Members
  • 13 posts
  • Local time: 05:25 AM

Posted 27 March 2020 - 12:26 PM

Hello,

Thank you for the awesome work you have done.

when I try to run main.py i get the following error

m3u2strm-nextgen\streamClasses.py", line 1
    pytimport asyncio
              ^
SyntaxError: invalid syntax

i went to streamcalsses.py and removed the first line. it ran for a second then gave another error.

Traceback (most recent call last):
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\main.py", line 6, in <module>
    examplelist = streamClasses.rawStreamList('TV-VOD-2020-03-27.m3u')
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\streamClasses.py", line 125, in __init__
    self.parseLine()
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\streamClasses.py", line 157, in parseLine
    self.parseStream(thisline, nextline)
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\streamClasses.py", line 198, in parseStream
    self.parseVodTv(streaminfo, streamURL)
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\streamClasses.py", line 214, in parseVodTv
    episodeinfo = tools.parseEpisode(title)
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\tools.py", line 202, in parseEpisode
    if seasonepisode.end() - seasonepisode.start() > 6 or len(seasonepisode.group()) == 5:
AttributeError: 'str' object has no attribute 'end'

 



#35 t1m OFFLINE  

t1m

    Advanced Member

  • Members
  • 35 posts
  • Local time: 08:25 AM

Posted 27 March 2020 - 12:47 PM

 

Hello,

Thank you for the awesome work you have done.

when I try to run main.py i get the following error

m3u2strm-nextgen\streamClasses.py", line 1
    pytimport asyncio
              ^
SyntaxError: invalid syntax

i went to streamcalsses.py and removed the first line. it ran for a second then gave another error.

Traceback (most recent call last):
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\main.py", line 6, in <module>
    examplelist = streamClasses.rawStreamList('TV-VOD-2020-03-27.m3u')
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\streamClasses.py", line 125, in __init__
    self.parseLine()
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\streamClasses.py", line 157, in parseLine
    self.parseStream(thisline, nextline)
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\streamClasses.py", line 198, in parseStream
    self.parseVodTv(streaminfo, streamURL)
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\streamClasses.py", line 214, in parseVodTv
    episodeinfo = tools.parseEpisode(title)
  File "C:\Users\\Downloads\m3u2strm-nextgen\m3u2strm-nextgen\tools.py", line 202, in parseEpisode
    if seasonepisode.end() - seasonepisode.start() > 6 or len(seasonepisode.group()) == 5:
AttributeError: 'str' object has no attribute 'end'

I had that error too, I thought I fixed it.  I will have to push a code update, I will let you know here once it is done.



#36 t1m OFFLINE  

t1m

    Advanced Member

  • Members
  • 35 posts
  • Local time: 08:25 AM

Posted 27 March 2020 - 12:59 PM

I pushed an update and think i fixed that error now... Sorry for the hassle, it's still a Work In Progress.







Also tagged with one or more of these keywords: m3u, strm, vod, iptv

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users