Source contribution to WEBEPG (1 Viewer)

fjonson

Portal Member
February 5, 2005
15
0
This code handles the problems with DagensTv.com page layout for Sweden

One example
This is the last program for the day on one channel
If I run webepg as it is today this program will continue until the first program the next day or in this example to the next program that starts at 08:00.
So if I want to record this program I will record from 04:45 until 08:00 instead of 04:45 until 05:35
I also added a new function to get the ShowView number.

  • 04:45
    Hulken (05:35)
    Amerikansk äventyrsserie från 1977-78. Del 7 av 16. David vaknar upp med en död fotomodell och är rädd för att han dödat henne då han var Hulken. Gästskådespelare: Loni Anderson. [4764572]


One suggestion from the time zone function use the English time zone name and add then following line. Other wise the time zone function is useless in my world.

RCS file: /cvsroot/mediaportal/mediaportal/Utils/Time/WorldTimeZone.cs,v
retrieving revision 1.7
diff -w -b -r1.7 WorldTimeZone.cs
275a276
> m_TimeZoneList.Add((string)timeZoneKeys, TZInfo);


First the changes needed in grabber xml file

RCS file: /cvsroot/mediaportal/mediaportal/WebEPG/WebEPG-xmltv/bin/Release/grabbers/SE/www_dagenstv_com.xml,v
retrieving revision 1.4
diff -w -b -r1.4 www_dagenstv_com.xml
147c147
< <td><#TITLE><br><#DESCRIPTION></td>
---
> <td><#TITLE#,(#END#),[#SHOWWVIEW#]><br><#DESCRIPTION#,[#SHOWWVIEW#]></td>
156a157,162
>
> <section name="Info">
> <entry name="GuideDays">14</entry>
> <entry name="TimeZone">W. Europe Standard Time</entry>
> <entry name="Lang">se</entry>
> </section>

And the changes to the code

RCS file: /cvsroot/mediaportal/mediaportal/WebEPG/WebEPG/Parser/ProgramData.cs,v
retrieving revision 1.4
diff -w -b -r1.4 ProgramData.cs
23a24
> using System.Collections.Generic;
35a37
> public Int32 ShowView = 0;
67a70,72
> case "<#SHOWWVIEW>":
> ShowView = int.Parse(element.Trim(' ', '\n', '\t'));
> break;
68a74,85
> HandleSpecialTag(tag,element);
> break;
> }
> }
> public int GetCountOf(string search, string data)
> {
> int startindex = -1;
> int count = 0;
> while (true)
> {
> startindex = data.IndexOf(search, startindex + 1, data.Length - startindex - 1);
> if (startindex < 0)
69a87
> count++;
70a89,110
> return count;
> }
> public void HandleSpecialTag(string tag, string element)
> {
> int startIndex = 0;
> int endIndex = -1;
> string BeginStr = String.Empty;
> string EndStr = String.Empty;
> bool DataRemains = true;
> List<string> Tags = new List<string>();
> if (GetCountOf("#", tag) < 2)
> return;
> while (DataRemains)
> {
> endIndex = tag.IndexOf(',', startIndex + 1, tag.Length - startIndex - 1);
> // end the loop if the no more target found.
> if (endIndex < 0)
> {
> DataRemains = false;
> if (Tags.Count > 0)
> {
> Tags.Add(tag.Substring(startIndex + 1, tag.Length - startIndex - 2));
71a112,132
> else
> {
> Tags.Add(tag.Substring(1, tag.Length - 2));
> }
> }
> else
> {
> Tags.Add(tag.Substring(startIndex+1, endIndex - startIndex - 1));
> startIndex = endIndex;
> }
>
> }
> for (int i = 0; i < Tags.Count; i++)
> {
> if (((Tags.Substring(0, 1) != "#") | (Tags.Substring(Tags.Length-1) != "#")) && (GetCountOf("#",Tags) > 1))
> {
> if (element.IndexOf(Tags.Substring(0,Tags.IndexOf('#'))) > -1)
> {
> startIndex = -1;
> endIndex = -1;
> string TmpData = String.Empty;
72a134,171
> // Search for all occurrences of the target.
> while (true)
> {
> if (startIndex + 1 > element.Length) startIndex = -1;
> startIndex = element.IndexOf(Tags.Substring(0, Tags.IndexOf('#')), startIndex + 1, element.Length - startIndex - 1);
> // Exit the loop if the target is not found.
> if (startIndex < 0)
> break;
> endIndex = element.IndexOf(Tags.Substring(Tags.LastIndexOf('#') + 1), startIndex + 1, element.Length - startIndex - 1) + 1;
> if (endIndex < 0)
> break;
> TmpData = element.Substring(startIndex, endIndex - startIndex);
> if ((Tags.IndexOf("START") > -1) | (Tags.IndexOf("END") > -1))
> {
> if (TmpData.IndexOf(':') > -1)
> {
> SetElement("<" + Tags.Substring(Tags.IndexOf('#'), Tags.LastIndexOf('#')) + ">", TmpData.Substring(1, TmpData.Length - 2));
> element = element.Remove(startIndex, endIndex - startIndex);
> }
> }
> else
> {
> SetElement("<" + Tags.Substring(Tags.IndexOf('#'), Tags.LastIndexOf('#') - Tags.IndexOf('#')) + ">", TmpData.Substring(1, TmpData.Length - 2));
> element = element.Remove(startIndex, endIndex - startIndex);
> }
> }
> }
> }
> }
> for (int i = 0; i < Tags.Count; i++)
> {
> if ((Tags.Substring(0, 1) == "#") && (Tags.Substring(Tags.Length-1) == "#"))
> {
> SetElement("<" + Tags.Substring(Tags.IndexOf('#'), Tags.LastIndexOf('#') - Tags.IndexOf('#')) + ">", element);
> }
> }
> Tags.Clear();
> }
 

James

Retired Team Member
  • Premium Supporter
  • May 6, 2005
    1,385
    67
    Switzerland
    Hi fjonson,

    Thanks for the contribution, which I haven't had time to look at in detail. However, a code change wasn't needed to get the end time.

    The following template should work:

    <td><#TITLE>(<#END>)
    <#DESCRIPTION></td>


    With the TimeZone function, both names are supported English and the Local language of the system. So that the following will work:

    WorldTimeZone tz = new WorldTimeZone(TimeZone.CurrentTimeZone.StandardName);

    Although all WebEPG config files will always use the English or Registry Key name.

    Cheers,

    /James
     

    fjonson

    Portal Member
    February 5, 2005
    15
    0
    Hello James

    Sorry to disappoint you but the changes in the grabber you suggest. Don’t work on dagenstv.

    Probably because END time don’t exists all the time, only on the last entry for the day or there is a longer break in the program.

    My suggestion is no universal solution but it helps.

    There is one issue that I don’t have solved you can se the issue in the output data.
    The program started at 0930 and continues until 1600 is a program containing several programs.
    In the program they only entered one sub program, this file will confuse mediaportal two program starting on the same time and same channel.
    I don’t think the solution is to implement some blocking in webepg I think this changes must be done in mediaportals EPG.

    /Fjonson

    Before your suggestion with the original file output data locks like this

    Code:
      <programme start="20060227093000" channel="24@svt.se">
        <title>24 direkt (16:00)</title>
        <desc>Politik, samhälle och kultur. Nyheter från Rapport varje hel timme.[44947911]</desc>
      </programme>
      <programme start="20060227093000" channel="24@svt.se">
        <title>Sametinget</title>
        <desc>Från Sametinget i Sorsele. Diskussion och debatt om gränsdragning, fiskerätter samt de finska och sydsamiska språken med anledning av tre statliga utredningar. Inspelat 21-22 februari. Reporter Arvid Lagercrantz.[44947911]</desc>
      </programme>
      <programme start="20060227160000" channel="24@svt.se">
        <title>Rapport[69312640]</title>
      </programme>
      <programme start="20060227161000" channel="24@svt.se">
        <title>24 vision</title>
        <desc>Senaste nytt från svt.se.[71985195]</desc>
      </programme>
      <programme start="20060227163000" channel="24@svt.se">
        <title>Rapport[50683485]</title>
      </programme>
    After making the changes you recommended the output result locks like this

    Code:
      <programme start="20060227093000" stop="20060227160000" channel="24@svt.se">
        <title>24 direkt</title>
        <desc>Politik, samhälle och kultur. Nyheter från Rapport varje hel timme.[44947911]</desc>
      </programme>
      <programme start="20060227093000" channel="24@svt.se">
        <title>Sametinget
    Från Sametinget i Sorsele. Diskussion och debatt om gränsdragning, fiskerätter samt de finska och sydsamiska språken med anledning av tre statliga utredningar. Inspelat 21-22 februari. Reporter Arvid Lagercrantz.[44947911]</title>
      </programme>
      <programme start="20060227160000" channel="24@svt.se">
        <title>Rapport[69312640]</title>
      </programme>
      <programme start="20060227161000" channel="24@svt.se">
        <title>24 vision
    Senaste nytt från svt.se.[71985195]</title>
      </programme>
      <programme start="20060227163000" channel="24@svt.se">
        <title>Rapport[50683485]</title>
      </programme>
    After my changes the output result looks like this.

    Code:
      <programme start="20060227093000" stop="20060227160000" channel="24@svt.se">
        <title>24 direkt</title>
        <desc>Politik, samhälle och kultur. Nyheter från Rapport varje hel timme. </desc>
      </programme>
      <programme start="20060227093000" channel="24@svt.se">
        <title>Sametinget</title>
        <desc>Från Sametinget i Sorsele. Diskussion och debatt om gränsdragning, fiskerätter samt de finska och sydsamiska språken med anledning av tre statliga utredningar. Inspelat 21-22 februari. Reporter Arvid Lagercrantz. </desc>
      </programme>
      <programme start="20060227160000" channel="24@svt.se">
        <title>Rapport</title>
      </programme>
      <programme start="20060227161000" channel="24@svt.se">
        <title>24 vision</title>
        <desc>Senaste nytt från svt.se. </desc>
      </programme>
      <programme start="20060227163000" channel="24@svt.se">
        <title>Rapport</title>
      </programme>
     

    James

    Retired Team Member
  • Premium Supporter
  • May 6, 2005
    1,385
    67
    Switzerland
    Hi fjonson,

    Thanks for your detailed reply. This shouldn't be happening. The system should be able to deal with fields that are not always there. I will check this.

    I agree code to deal with subprograms or multiple programs for a give time slot should be in MP when it loads the xmltv file. As this could be of use to more then just WebEPG.

    /James
     

    SweMart

    MP Donator
  • Premium Supporter
  • March 25, 2006
    359
    11
    47
    Stockholm, Sweden
    Home Country
    Sweden Sweden
    The following template should work:

    <td><#TITLE>(<#END>)
    <#DESCRIPTION></td>

    Anything new on this topic?

    I've tried to configure the grabber so that it picks up the intermittent END without any luck, it's really annoying to record a one hour program for 9 hours :(

    I refuse to start using xmltv, the WebEPG setup is so much easier and quicker.
     

    fjonson

    Portal Member
    February 5, 2005
    15
    0
    Hello!

    I did not hear any thing and I can't get it to work with James code. So I returned to my own code published earlier in this thread.

    As a bonus this codes also eliminate the showview number, and this is good.
    If the showview nr is in the Title webepg add the showview to the end of the title. That means every program is different and you can't se if this program is transmitted any more times based on the title.

    /Fjonson
     

    James

    Retired Team Member
  • Premium Supporter
  • May 6, 2005
    1,385
    67
    Switzerland
    Hi Guys,

    I not ignoring you, just not much time lately.

    SweMart, I will take a look at your changes, may not be for a few days tho.

    fjonson, I did look at your code a the problem. I wanted to change the engine a bit to fix this and make it more robust, but I thought these change were a little big until after 0.2. Which could be any day now for the last month.

    I will have a look again and see I can make a more quick fix change.

    /James
     

    Users who are viewing this thread

    Top Bottom