bebo-dot-dev / m3u-epg-editor

a python m3u / epg optimizer
120 stars 27 forks source link

weird pseudo programme being made #82

Closed mLgz0rn closed 2 weeks ago

mLgz0rn commented 6 months ago

Hello!

I don't know if you are still active on this repo, but i'll try anyways :D

I am having an issue with m3u-epg-editor creating some weird pseudo programme's when force_epg and no_tvg_id is enabled for channels that has no tvg_id. The start/stop times are completely wrong, and it's not even creating enough to correspond with the range set. It seems that the stop times being created are just set to the same date and time for all entries And start times does not match even, and there's not even enough to last all hours of one day.

it looks like this

  <programme start="20240315230000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240316010000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240316050000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240316110000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240316190000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240317050000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240317170000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240318070000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240318230000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240319170000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240320130000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
  <programme start="20240321110000 +0000" stop="20240316010000 +0000" channel="DR Event 1 HD DK">
    <title>DR Event 1 HD DK</title>
    <desc>DR Event 1 HD DK</desc>
  </programme>
bebo-dot-dev commented 6 months ago

hey, yes still here :)

So the original idea of the --force_epg / -fe option coupled with the --no_tvg_id / -nt option was to force into existence some sort of placebo EPG data when no EPG data actually existed to begin with. To be completely honest this feature was quite an odd desire but it made complete sense to the guy who originally asked for it in issue https://github.com/bebo-dot-dev/m3u-epg-editor/issues/42 who needed it to make Plex/Emby work with his crap EPG source data :)

To answer your question, if you decide to use this feature with poor quality source M3U and EPG source you can 100% expect nonsense EPG to end up being generated into the newly created EPG XML file because the python script in this project can't guess what the complete and coherent EPG XML data is when no source EPG XML data actually existed to begin with ;)

Use this switch if it makes sense for your use case, if it doesn't work for what you're wanting and needing don't bother.

mLgz0rn commented 6 months ago

I know a few other apps that has this kind of feature, and was hoping it would be kinda like that. Xteve for instance. You can have it add dummies and dummy data for channels that has no epg data, and I thought it would work like that here :p.

I kinda fixed it myself by doing this

        if args.no_tvg_id and args.force_epg:
            # create programme elements for every channel present in the m3u where there is no tvg_id and where there is a tvg_name value
            for entry in m3u_entries:
                if entry.tvg_id is None or entry.tvg_id == "" or entry.tvg_id == "None":
                    output_str("creating pseudo programme elements for m3u entry {}".format(entry.tvg_name))
                    programme_start_timestamp = datetime.datetime.now(tzlocal.get_localzone())
                    programme_stop_timestamp = programme_start_timestamp + datetime.timedelta(hours=2)
                    max_programme_start_timestamp = max_programme_start_timestamp if programme_start_timestamp > max_programme_start_timestamp else programme_start_timestamp
                    for i in range(1, 168): # create programme elements within a max 7 day window and no more limited by the configured range
                        if is_in_range(args, programme_start_timestamp):
                            programme_count += 1
                            programme = SubElement(new_root, "programme")
                            programme.set("start", programme_start_timestamp.strftime("%Y%m%d%H0000 %z"))
                            programme.set("stop", programme_stop_timestamp.strftime("%Y%m%d%H0000 %z"))
                            programme.set("channel", entry.tvg_name)
                            title_elem = SubElement(programme, "title")
                            title_elem.text = entry.tvg_name
                            desc_elem = SubElement(programme, "desc")
                            desc_elem.text = entry.tvg_name
                            programme_start_timestamp = programme_start_timestamp + datetime.timedelta(hours=2)
                            programme_stop_timestamp = programme_stop_timestamp + datetime.timedelta(hours=2)

instead of

        if args.no_tvg_id and args.force_epg:
            # create programme elements for every channel present in the m3u where there is no tvg_id and where there is a tvg_name value
            for entry in m3u_entries:
                if entry.tvg_id is None or entry.tvg_id == "" or entry.tvg_id == "None":
                    output_str("creating pseudo programme elements for m3u entry {}".format(entry.tvg_name))
                    programme_start_timestamp = datetime.datetime.now(tzlocal.get_localzone())
                    programme_stop_timestamp = programme_start_timestamp + datetime.timedelta(hours=2)
                    max_programme_start_timestamp = max_programme_start_timestamp if programme_start_timestamp > max_programme_start_timestamp else programme_start_timestamp
                    for i in range(1, 84): # create programme elements within a max 7 day window and no more limited by the configured range
                        if is_in_range(args, programme_start_timestamp):
                            programme_count += 1
                            programme = SubElement(new_root, "programme")
                            programme.set("start", programme_start_timestamp.strftime("%Y%m%d%H0000 %z"))
                            programme.set("stop", programme_stop_timestamp.strftime("%Y%m%d%H0000 %z"))
                            programme.set("channel", entry.tvg_name)
                            title_elem = SubElement(programme, "title")
                            title_elem.text = entry.tvg_name
                            desc_elem = SubElement(programme, "desc")
                            desc_elem.text = entry.tvg_name
                            programme_start_timestamp = programme_start_timestamp + datetime.timedelta(hours=i * 2)
bebo-dot-dev commented 5 months ago

Well if that works for you it works and I'm sort of inclined to take your change and merge it given how few people I suspect use this feature.

bebo-dot-dev commented 2 weeks ago

Merged the suggsted fix in https://github.com/bebo-dot-dev/m3u-epg-editor/commit/8f044096b5647e707b4c191c929f41aa8f3885e8