Jump to content

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


t1m

Recommended Posts

Webdoc
3 minutes ago, hooray4me said:

are you setting the singlelisturl? also the path to the folder for tvshows, is the wedoc user and group the owner? maybe also chmod 777 that folder.

Singlelist is set I just removed it to post here, path to tvshows and movies is set in the compose file, webdoc is group owner, permissions allow other containers to access so should be ok.

Link to comment
Share on other sites

hooray4me
3 hours ago, Webdoc said:

Singlelist is set I just removed it to post here, path to tvshows and movies is set in the compose file, webdoc is group owner, permissions allow other containers to access so should be ok.

does this help? This is one of my production setups...
 

cat /etc/passwd
admin:x:1024:100::/home/admin:/bin/bash

ls -la /mnt/emby/streaming/tv/
drwxrwxrwx 1 admin users 116242 Apr 17 19:10 subscription1
ls -la /mnt/emby/streaming/movies/
drwxrwxrwx 1 admin users 671482 Apr 19 19:40 subscription1

version: "3"
services:
  streamgen:
    image: ghcr.io/hooray4me/ustreamgen:v1.37
    container_name: ustreamgen
    command: /root/initialize_cron.sh
    environment:
      - PUID=1024
      - PGID=100
      - UID=1024
      - GID=100
      - UNAME=admin
      - GROUP=users
      - SINGLELIST=false
      - MOVIES=true
      - TVSHOWS=true
      - EVENTS=false
      - CRONHOUR=0
      - CRONMINUTE=10
      - TVCRONHOUR=0
      - TVCRONMINUTE=10
      - MOVIECRONHOUR=0
      - MOVIECRONMINUTE=40
      - EVENTCRONHOUR=0
      - EVENTCRONMINUTE=30
      - TZ=America/Chicago
      - SINGLELISTURL=https://tvnow.best/api/list/user/pass/m3u8/movies/
      - MOVIEURL=https://tvnow.best/api/list/user/pass/m3u8/movies/
      - TVSHOWURL=https://tvnow.best/user/pass/m3u8/tvshows/
      - EVENTURL=https://tvnow.best/api/list/user/pass/m3u8/events/
      - APOLLO=true
    volumes:
      - /mnt/emby/streaming/tv/subscription1:/tv
      - /mnt/emby/streaming/movies/subscription1:/movies
      - ./logs:/logs
    restart: unless-stopped

Also I think the SINGLELIST variable would still point to the /tv folder

 

    volumes:
      - /path/to/folder/for/tv/strm/files:/tv

You could also try leaving it default like

      - PUID=1000
      - PGID=1000
      - UID=1000
      - GID=1000
      - UNAME=root
      - GROUP=root

and just make sure the the directories you want to write too are chmod 777

Edited by hooray4me
Link to comment
Share on other sites

Webdoc
13 hours ago, hooray4me said:

does this help? This is one of my production setups...
 

cat /etc/passwd
admin:x:1024:100::/home/admin:/bin/bash

ls -la /mnt/emby/streaming/tv/
drwxrwxrwx 1 admin users 116242 Apr 17 19:10 subscription1
ls -la /mnt/emby/streaming/movies/
drwxrwxrwx 1 admin users 671482 Apr 19 19:40 subscription1

version: "3"
services:
  streamgen:
    image: ghcr.io/hooray4me/ustreamgen:v1.37
    container_name: ustreamgen
    command: /root/initialize_cron.sh
    environment:
      - PUID=1024
      - PGID=100
      - UID=1024
      - GID=100
      - UNAME=admin
      - GROUP=users
      - SINGLELIST=false
      - MOVIES=true
      - TVSHOWS=true
      - EVENTS=false
      - CRONHOUR=0
      - CRONMINUTE=10
      - TVCRONHOUR=0
      - TVCRONMINUTE=10
      - MOVIECRONHOUR=0
      - MOVIECRONMINUTE=40
      - EVENTCRONHOUR=0
      - EVENTCRONMINUTE=30
      - TZ=America/Chicago
      - SINGLELISTURL=https://tvnow.best/api/list/user/pass/m3u8/movies/
      - MOVIEURL=https://tvnow.best/api/list/user/pass/m3u8/movies/
      - TVSHOWURL=https://tvnow.best/user/pass/m3u8/tvshows/
      - EVENTURL=https://tvnow.best/api/list/user/pass/m3u8/events/
      - APOLLO=true
    volumes:
      - /mnt/emby/streaming/tv/subscription1:/tv
      - /mnt/emby/streaming/movies/subscription1:/movies
      - ./logs:/logs
    restart: unless-stopped

Also I think the SINGLELIST variable would still point to the /tv folder

 

    volumes:
      - /path/to/folder/for/tv/strm/files:/tv

You could also try leaving it default like

      - PUID=1000
      - PGID=1000
      - UID=1000
      - GID=1000
      - UNAME=root
      - GROUP=root

and just make sure the the directories you want to write too are chmod 777

Above not running

yaml: line 8: could not find expected ':'

 

Link to comment
Share on other sites

Webdoc
14 minutes ago, Webdoc said:

Above not running

yaml: line 8: could not find expected ':'

 

Implicit map keys need to be followed by map values at line 8, column 1
Implicit map keys need to be followed by map values at line 9, column 1
Implicit map keys need to be followed by map values at line 10, column 1
Implicit map keys need to be followed by map values at line 11, column 1
Implicit map keys need to be followed by map values at line 12, column 1
Implicit map keys need to be followed by map values at line 13, column 1
Implicit map keys need to be followed by map values at line 14, column 1
Implicit map keys need to be followed by map values at line 15, column 1
Implicit map keys need to be followed by map values at line 16, column 1
Implicit map keys need to be followed by map values at line 17, column 1
Implicit map keys need to be followed by map values at line 18, column 1
Implicit map keys need to be followed by map values at line 19, column 1
Implicit map keys need to be followed by map values at line 20, column 1
Implicit map keys need to be followed by map values at line 21, column 1
Implicit map keys need to be followed by map values at line 22, column 1
Implicit map keys need to be followed by map values at line 23, column 1
Implicit map keys need to be followed by map values at line 24, column 1
Implicit map keys need to be followed by map values at line 25, column 1
Implicit map keys need to be followed by map values at line 26, column 1
Implicit map keys need to be followed by map values at line 27, column 1
Implicit map keys need to be followed by map values at line 28, column 1
Implicit map keys need to be followed by map values at line 29, column 1
Implicit map keys need to be followed by map values at line 30, column 1
Implicit map keys need to be followed by map values at line 31, column 1
Implicit keys need to be on a single line at line 33, column 1
Implicit map keys need to be followed by map values at line 33, column 1
Implicit map keys need to be followed by map values at line 35, column 1

Link to comment
Share on other sites

hooray4me

that was my example declaring the evs in the docker compose instead of the env file... depending on how you're specifying them, will determine syntax.

heading to church, can explain more later

Link to comment
Share on other sites

hooray4me
3 hours ago, Webdoc said:

Implicit map keys need to be followed by map values at line 8, column 1
Implicit map keys need to be followed by map values at line 9, column 1
Implicit map keys need to be followed by map values at line 10, column 1
Implicit map keys need to be followed by map values at line 11, column 1
Implicit map keys need to be followed by map values at line 12, column 1
Implicit map keys need to be followed by map values at line 13, column 1
Implicit map keys need to be followed by map values at line 14, column 1
Implicit map keys need to be followed by map values at line 15, column 1
Implicit map keys need to be followed by map values at line 16, column 1
Implicit map keys need to be followed by map values at line 17, column 1
Implicit map keys need to be followed by map values at line 18, column 1
Implicit map keys need to be followed by map values at line 19, column 1
Implicit map keys need to be followed by map values at line 20, column 1
Implicit map keys need to be followed by map values at line 21, column 1
Implicit map keys need to be followed by map values at line 22, column 1
Implicit map keys need to be followed by map values at line 23, column 1
Implicit map keys need to be followed by map values at line 24, column 1
Implicit map keys need to be followed by map values at line 25, column 1
Implicit map keys need to be followed by map values at line 26, column 1
Implicit map keys need to be followed by map values at line 27, column 1
Implicit map keys need to be followed by map values at line 28, column 1
Implicit map keys need to be followed by map values at line 29, column 1
Implicit map keys need to be followed by map values at line 30, column 1
Implicit map keys need to be followed by map values at line 31, column 1
Implicit keys need to be on a single line at line 33, column 1
Implicit map keys need to be followed by map values at line 33, column 1
Implicit map keys need to be followed by map values at line 35, column 1

One thing, can manually pull the m3u file down, edit it and do a find and replace for your credentials and replace with something generic like user/password and then upload here. I've tried to make this as universal as possible, but it could have to do with the format of the m3u data.

Link to comment
Share on other sites

Webdoc
14 minutes ago, hooray4me said:

One thing, can manually pull the m3u file down, edit it and do a find and replace for your credentials and replace with something generic like user/password and then upload here. I've tried to make this as universal as possible, but it could have to do with the format of the m3u data.

will 6 or so lines from series and movie sections help?

Link to comment
Share on other sites

hooray4me
28 minutes ago, Webdoc said:

will 6 or so lines from series and movie sections help?

Well I was going to try and replicate what you're trying to do... so the whole m3u (sanatized) would be the most helpful... I should be able to run the streamgen over the whole thing and have it create the structure, even if the url's don't really go anywhere.

Heading to kids soccer, can look at this more later!

Link to comment
Share on other sites

hooray4me
1 hour ago, Webdoc said:

tv_channels_plus.m3uHope this helps

And thanks again for your time

Your m3u is missing key information for the script to know the content type, specifically tvg-type.

The parser has no way of knowing what content is what... you'd need to find a way to delineate the types. 

movie example
#EXTINF:-1 tvg-id="tt14412366" tvg-name="tt14412366" tvg-type="movies" group-title="Movies 2022" ,A Day to Die (2022)
https://tvnow.best/api/stream/user/password/movie/tt14412366

tv series example
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E01
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/1
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E02
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/2
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E03
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/3
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E04
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/4
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E05
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/5
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E06
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/6
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E07
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/7
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E08
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/8
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E09
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/9
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E10
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/10
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E11
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/11
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E12
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/12
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E13

Link to comment
Share on other sites

hooray4me
1 minute ago, hooray4me said:

Your m3u is missing key information for the script to know the content type, specifically tvg-type.

The parser has no way of knowing what content is what... you'd need to find a way to delineate the types. 

movie example
#EXTINF:-1 tvg-id="tt14412366" tvg-name="tt14412366" tvg-type="movies" group-title="Movies 2022" ,A Day to Die (2022)
https://tvnow.best/api/stream/user/password/movie/tt14412366

tv series example
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E01
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/1
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E02
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/2
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E03
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/3
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E04
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/4
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E05
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/5
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E06
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/6
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E07
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/7
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E08
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/8
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E09
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/9
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E10
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/10
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E11
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/11
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E12
https://tvnow.best/api/stream/user/password/tvshow/tt11055882/1/12
#EXTINF:-1 tvg-id="tt11055882" tvg-name="tt11055882" tvg-type="tvshows" group-title="Good Sam (2022)" ,Good Sam (2022) S01 E13

off the top of my head, I may be able to add some custom parsing logic for the stream url, but that will take some code change/additional logic operators...

http://address:80/series/user/pass/495353.mp4 = tvshows

http://address:80/movie/user/pass/379248.mp4 =  movie

Link to comment
Share on other sites

hooray4me
6 minutes ago, hooray4me said:

off the top of my head, I may be able to add some custom parsing logic for the stream url, but that will take some code change/additional logic operators...

http://address:80/series/user/pass/495353.mp4 = tvshows

http://address:80/movie/user/pass/379248.mp4 =  movie

though, this logic should already be there for single list. I will run through a couple tests and see if it is a configuration issue.

Link to comment
Share on other sites

Webdoc
2 minutes ago, hooray4me said:

though, this logic should already be there for single list. I will run through a couple tests and see if it is a configuration issue.

Would it be better if the provider can alter the file they use?

Link to comment
Share on other sites

hooray4me
On 4/21/2024 at 4:09 PM, Webdoc said:

Would it be better if the provider can alter the file they use?

I am getting farther... there are some specific permissions things... but I got it to run and create movies and tvshow... though one big issue is that the name of the stream includes a prefix like 4K-A+ - 9_11- etc... so it created the movie and tv directories is the same way.
image.png.14addd046e2969c3322b61328699e341.png

Link to comment
Share on other sites

Webdoc

Your getting along better than I would be able too, I'm sure you will work it out

Thanks again

Link to comment
Share on other sites

hooray4me
2 hours ago, Webdoc said:

Your getting along better than I would be able too, I'm sure you will work it out

Thanks again

Try this config... See the notes on each variable.
 

Quote
version: "3"
services:
  streamgen:
    image: ghcr.io/hooray4me/ustreamgen:v1.51-dev
    container_name: ustreamgen
    command: /m3u2strm/initialize_cron.sh
    environment:
      - PUID=1000 #make sure this is the numeric uid of webdoc
      - PGID=1000 #make sure this is the numeric gid of webdoc
      - UID=1000 #make sure this is the numeric uid of webdoc
      - GID=1000 #make sure this is the numeric gid of webdoc
      - UNAME=webdoc
      - GROUP=webdoc
      - TZ=Europe/London
      - SINGLELIST=true
      - SINGLELISTURL=https://m3uurl #replace with your url
      - TVSHOWURL=https://m3uurl  #replace with your url
      - MOVIEURL=https://m3uurl  #replace with your url
      - CRONMINUTE=10
      - CRONHOUR=00
      - MOVIES=true
      - TVSHOWS=true
      - EVENTS=false
      - APOLLO=false
    volumes:
      - /path/to/tv:/tv # /path/to/tv must be chmod 777 and folder owner must be chown webdoc:webdoc
      - /path/to/movies:/movies # /path/to/movies must be chmod 777 and folder owner must be chown webdoc:webdoc
      - ./logs:/logs # ./logs must be chmod 777
    restart: unless-stopped

 

 

 

Link to comment
Share on other sites

Webdoc
13 hours ago, hooray4me said:

Try this config... See the notes on each variable.
 

 

Hello, used the above with my url & path to folders ran as a stack in portainer and the container is running however that as far as it went, I think the folder is 777 but see attached log and image. 

Just a thought could some of the problems be because my m3u file ends with the following

&type=m3u_plus&output=ts

Thanks againustreamgen_logs.txt

permissions.png

Edited by Webdoc
Link to comment
Share on other sites

Thefalfr

The new version you posted 

On 4/23/2024 at 2:36 AM, hooray4me said:

Try this config... See the notes on each variable.
 

 

This works for me. Is it possible to filter out xxx videos?

Link to comment
Share on other sites

hooray4me
7 hours ago, Thefalfr said:

The new version you posted 

This works for me. Is it possible to filter out xxx videos?

Can you provide an example of an xxx m3u entry? Would need to figure out the identifier...

Link to comment
Share on other sites

Hi hooray4me,

I'm using the updated docker-compose you provided to Webdoc for a docker I'm running on a mac.  I can get the docker to run and pull and create the .strm files, but noticed that the cron jobs do not run.  In the logs I can see this: "no cronjob for root". Also, the cron.log file is empty.

I also noticed that the cron-movies.log only shows "...Starting Download...", but it is working.

Here is my sanitized compose yaml:

version: "3"
services:
  streamgen:
    image: ghcr.io/hooray4me/ustreamgen:v1.51-dev
    container_name: ustreamgen
    command: /m3u2strm/initialize_cron.sh
    environment:
      - UID=501 #UID for file ownership
      - GID=20 #GID for file ownership
      - UNAME=aaron #Username for file ownership
      - GROUP=staff #Group name for file ownership
      - SINGLELIST=false #when true a single list of movies, series and events is used. flase for multiple lists
      - MOVIES=true #set to false if movies are not desired
      - TVSHOWS=true #set to false if tv shows are not desired
      - EVENTS=true # set to false is live sporting events are not desired
      - CRONHOUR=0 #0-23 # sets the hour of the day the script will run again for all content in 1 list **ALL must be true
      - CRONMINUTE=10 #0-59 # sets the minute of the day the script will run again for all content 1 list **ALL must be true
      - TVCRONHOUR=0 #0-23 # sets the hour of the day the script will run again for tv shows **TVSHOWS must be true
      - TVCRONMINUTE=10 #0-59 # sets the minute of the day the script will run again for tv shows **TVSHOWS must be true
      - MOVIECRONHOUR=0 #0-23 # sets the hour of the day the script will run again for movies **MOVIES must be true
      - MOVIECRONMINUTE=20 #0-59 # sets the minute of the day the script will run again for movies **MOVIES must be true
      - EVENTCRONHOUR=0 #0-23 # sets the hour of the day the script will run again for events **EVENTS must be true
      - EVENTCRONMINUTE=30 #0-59 # sets the minute of the day the script will run again for events **EVENTS must be true
      - TZ=America/New_York
      - SINGLELISTURL=https://tvnow.best/api/list/*redacted*/m3u8/movies/ # Full M3U Provider URL for all content in one list **SINGLELIST must be true
      - MOVIEURL=https://tvnow.best/api/list/*redacted*/m3u8/movies/ # Full M3U Provider URL for Movies **MOVIES must be true
      - TVSHOWURL=https://tvnow.best/api/list/*redacted*/m3u8/tvshows/ # Full M3U Provider URL for TV Shows **TVSHOWS must be true
      - EVENTURL=https://tvnow.best/api/list/*redacted*/m3u8/events/ # Full M3U Provider URL for Events **EVENTS must be true
      - APOLLO=true #Optional change to true if your Provider is Apollo
    volumes:
      - $PWD/tv:/tv
      - $PWD/movies:/movies
      - $PWD/events:/events
      - $PWD/logs:/logs

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...