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.
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();
> }
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();
> }
Sweden