You are here

Practical? The use and effect of argument scope

9 posts / 0 new
Last post
Kick4U
Offline
Donator
Joined: 6 years
Last seen: 5 months
Practical? The use and effect of argument scope

Hello, I would like to know if myidea is practical with WebGrab ini file.

I have xml file being created with multiple categories.  The first category is always "TV" or "Movies" and is scrubbed independent of the others (seperate line item within the ini file).  I want to compare the first category with the others and rename them depending on the comparison.

The trick I'm concerned about is storing the first attribute of the category element as a variable and using it as for an if than loop.  Is this possible?  Perhaps it will need to be a post-process script?

First Example xml (TV/Drama):

    <category lang="en">TV</category>
    <category lang="en">Series</category>
    <category lang="en">Drama</category>

Comparison: Looks at first category is 'TV' and checks for 'Drama' in all other category listings.  If found, replaces 'Drama' line with 'Show/Game show'.

Final:

    <category lang="en">TV</category>
    <category lang="en">Series</category>
    <category lang="en">Show/Game show</category>

Second Example xml (Movies/Drama):

    <category lang="en">Movies</category>
    <category lang="en">Romance</category>
    <category lang="en">Kids</category>
    <category lang="en">Kids &amp; Family</category>
    <category lang="en">Drama</category>

 

Comparison: Looks at first category is 'Movies' and checks for 'Comedy' (correction: 'Drama') in all other category listings.  If found, replaces 'Comedy' (correction: 'Drama') line with 'Show/Game show'.

Final:

    <category lang="en">Movies</category>
    <category lang="en">Romance</category>
    <category lang="en">Kids</category>
    <category lang="en">Kids &amp; Family</category>
    <category lang="en">Movie/Drama</category>

Kick4U
Offline
Donator
Joined: 6 years
Last seen: 5 months

Thank You!
You're absolutely right about it not making much sense, but my backend will only import categories based on the ETSI EN 300 468 standard.  I need a way to segregate TV Shows and Movies and am currently replacing all TV tags to Show/Game show and Movies to Movie/Drama.  This way I can record using Show/Game and Movie/Drama as the parent folders and keeping TV Shows in a seperate folder than Movies.

Since the standard is limited (like Comedy only is for movies and there's no way to distinguish from TV sitcoms) this will allow me to have more detailed information in my guide and still seperate movies and tv shows (altough it does create a ton of directories).

 

I'm needing to create a temperary element in the form of an array.  Is this possible?  The idea is to run a loop to see if at least one category was renamed, but if their wasn't rename category tags with 'Comedy', 'Entertainment', and 'Reality' to 'Show/Game show'.  Since 'Show/Game show' is generic I don't want to rename anything to this unless nothing else was renamed.

 

Thank you

Kick4U
Offline
Donator
Joined: 6 years
Last seen: 5 months

This process is taking a very long time since it originally looped too many different 'replace' iterations for each episode.  I have removed all category tags that will always switch to "Show/Game Show" with after.sh script using 'sed'.

However, I still need this for category tags that are different for Movies and TV.  Here are the lines I'm using in my site.ini files.

loop{('category' ~ "Movies")|end}
category.modify {replace|Action|Adventure/Western/War}
loop{('category' not~ "Adventure/Western/War")|1}
category.modify {replace|Adventure|Adventure/Western/War}
category.modify {replace|Crime|Detective/Thriller}
loop{('category' not~ "Detective/Thriller")|1}
category.modify {replace|Detective|Detective/Thriller}
category.modify {replace|Drama|Movie/Drama}
loop{('category' not~ "Science fiction/Fantasy/Horror")|1}
category.modify {replace|Fantasy|Science fiction/Fantasy/Horror}
category.modify {replace|Features|Movie/Drama}
category.modify {replace|History|Serious/Clasical/Religious/Historical movie/drama}
loop{('category' not~ "Science fiction/Fantasy/Horror")|1}
category.modify {replace|Horror|Science fiction/Fantasy/Horror}
category.modify {replace|Kids|Movie/Drama}
category.modify {replace|Kids & Family|Movie/Drama}
category.modify {replace|Law|Movie/Drama}
category.modify {replace|Lifestyle|Movie/Drama}
category.modify {replace|Music|Movie/Drama}
category.modify {replace|Musical|Movie/Drama}
category.modify {replace|Mystery|Detective/Thriller}
category.modify {replace|Reality|Detective/Thriller}
category.modify {replace|Sci-Fi|Science fiction/Fantasy/Horror}
loop{('category' not~ "Science fiction/Fantasy/Horror")|1}
category.modify {replace|Science Fiction|Science fiction/Fantasy/Horror}
category.modify {replace|Suspense|Science fiction/Fantasy/Horror}
loop{('category' not~ "Detective/Thriller")|1}
category.modify {replace|Thriller|Detective/Thriller}
loop{('category' not~ "Adventure/Western/War")|1}
category.modify {replace|Western|Adventure/Western/War}
loop{('category' not~ "Adventure/Western/War")|1}
category.modify {replace|War|Adventure/Western/War}
end_loop

loop{('category' not~ "Movies")|end}
category.modify {replace|Action|Show/Game show}
category.modify {replace|Adventure|Show/Game show}
category.modify {replace|Comedy|Show/Game show}
category.modify {replace|Crime|Show/Game show}
loop{('category' not~ "Movie/Drama")|1}
category.modify {replace|Drama|Show/Game show}
category.modify {replace|Detective|Show/Game show}
category.modify {replace|Fantasy|Show/Game show}
category.modify {replace|Features|Show/Game show}
category.modify {replace|History|Magazines/Reports/Documentary}
category.modify {replace|Horror|Show/Game show}
category.modify {replace|Kids|Children's/Youth programmes}
category.modify {replace|Kids & Family|Children's/Youth programmes}
category.modify {replace|Law|Show/Game show}
category.modify {replace|Lifestyle|Show/Game show}
category.modify {replace|Music|Music/Ballet/Dance}
category.modify {replace|Mystery|Show/Game show}
category.modify {replace|Reality|Show/Game show}
category.modify {replace|Science Fiction|Show/Game show}
category.modify {replace|Suspense|Show/Game show}
category.modify {replace|Thriller|Show/Game show}
category.modify {replace|Western|Show/Game show}
category.modify {replace|War|Show/Game show}
end_loop

Do any of you know of a better way to implement this?

Thank You! 

Kick4U
Offline
Donator
Joined: 6 years
Last seen: 5 months

I'm prettier sure I was using the loop correctly, as it works as intended.  Here's from the manual:
lines : The number of lines (following the line specifying the loop) that are contained in the loop.
end : Alternative to lines specify the word end in combination with end_loop after the last line that belongs to the loop

That's besides the point, since my ini takes avg~ 2mins/channel running loops where regex streamlined that by cutting 50secs/channel.  Thank you for that hint!

Problem is, I'm trying to get about 400 DirecTV channels and it'll take over 7 hours to pull one day of information!  If this is the case, I'll need a dedicated SoC running WebGrab 1/3 of the day.  I guess it could be worse though! 

 

I've attached my ini files; with and without the regex hint with the logs showing the times.  Both acquired the desired xmltv file.

 

Attachments: 
Kick4U
Offline
Donator
Joined: 6 years
Last seen: 5 months

I'm not saying this method is correct for this situation, nor if loops within loops work or not... just that it somehow worked in this situation and could be from many other things.

I've now used both tips you've provided and have a grabber taking only 20secs/channel! Amazing.  Couldn't have done this without you Blackbear199

index_category.modify {replace(~ "Movies")(type=regex)|^Drama$|Movie/Drama}
This line eliminates all loops and prevents accidental duplicates.

 

Lastly, I'm going to try running a plain vanilla grab, than immediately run another grab of the wgfile with an edited merge-xmltv.ini using the above syntax.  I'm hoping this will help by working across the board for all ini updates in the future.

Ironic thing is that the merge-xmltv doesn't seem to work in on linux tonight???  Oh well, it's late anyways and I'll look into more another day.

 

Thank You Again!!!

Kick4U
Offline
Donator
Joined: 6 years
Last seen: 5 months

This new process is working great.  My guide is now color coded based on category edits I'm making.

The only thing I'm missing is the ability to change a category when either <category>TV</category> and/or <category>Series</category> are the only ones present.  Is there a way to combine the categories into a multiple field and test that using regex?

Unfortunately, there are alread 47 lines of replace and the merge extremely slow for a 7 day grab.  I'm thinking of combining categories so that if it matches it can edit the field and move onto the next programme.

Can I run regex within a loop like this?

loop{(type=regex)(~not ^News/Current affairs$)|end}
index_category.modify {replace|News & Documentaries|News/Current affairs}
index_category.modify {replace(type=regex)|^News$|News/Current affairs}
index_category.modify {replace|Politica|News/Current affairs}
end_loop

Kick4U
Offline
Donator
Joined: 6 years
Last seen: 5 months

So it seems to work for all elements with attributes that don't have the '&' sign.  The xml file ends up converting the '&' sign to '&amp;'.  Is there another trick you know of that would work with the line you provided above?

Tried:
index_category.modify {replace(type=regex)|^(?:News\|News & Documentaries\|Politica)$|News/Current affairs}
index_category.modify {replace(type=regex)|^(?:News\|News &amp; Documentaries\|Politica)$|News/Current affairs}
index_category.modify {replace|(News\|News & Documentaries\|Politica)|News/Current affairs}
index_category.modify {replace|(News\|News &amp; Documentaries\|Politica)|News/Current affairs}

Kick4U
Offline
Donator
Joined: 6 years
Last seen: 5 months

I am thankful for you support and guidance with my quest.  Changing the categories has made a drasctic cosmetic improvement to my EPG now that I have colors!

I have found that I need to use '&amp;' since I'm running this replace "script" as a second webgrab run using merge-xmltv.  This allows me to keep the site.ini files untouched and the replaces work on all future site.ini updates. (*side bar* does revision 4  that you made account for '&' sign within the category? I think it only does it for the xmltv-id).

The trouble I'm still having is with the debug line '[  Debug ] !! No match group definition () in :^(?:News|News & Documentaries|Politica)$'.  This will replace all categories with any of the grouped attributes.  I'm trying with no avail to replace only when all three are present and in this order (combining the three together to make one, instead of seperating them three times.  My hypothesis is that I need to make the indice a multiple value and compare all multple combinations, than I would need to convery it back to single to run all the single replaces.  Am I on the right path? I'm fresh with programming (I only took one course in C+ 10 years ago) and confuse myself with so many iterations of ini files.

[  Debug ] Debugging information SiteIni
[  Debug ] Element:  INDEX_CATEGORY
[  Debug ] Modify
[  Debug ]      command & arguments : replace(debug type=regex)
[  Debug ]      Expression-1            : ^(?:News|News &amp; Documentaries|Politica)$
[  Debug ]      Expression-2            : News/Current affairs
[  Debug ]      Element value before operation:
[  Debug ] News|News &amp; Documentaries|Politica
[  Debug ] !! No match group definition () in :^(?:News|News &amp; Documentaries|Politica)$

[  Debug ] Found 1 top level un-grouped match(es):
[  Debug ] News
[  Debug ] !! No match group definition () in :^(?:News|News &amp; Documentaries|Politica)$
[  Debug ] Found 1 top level un-grouped match(es):
[  Debug ] News &amp; Documentaries
[  Debug ] !! No match group definition () in :^(?:News|News &amp; Documentaries|Politica)$
[  Debug ] Found 1 top level un-grouped match(es):
[  Debug ] Politica
[  Debug ]      Element value after operation:
[  Debug ] News/Current affairs|News/Current affairs|News/Current affairs

 

Kick4U
Offline
Donator
Joined: 6 years
Last seen: 5 months

It does make sense and it's sort of what I was thinking.  Just didn't think of replacing th '|' to something else.  I'll replace the dividers, run my 'and' replaces; than return the dividers back for the rest of the replaces.

This is becoming very grueling on my processor and it seems I will soon need to find another external program to accomplish this.

Log in or register to post comments

Brought to you by Jan van Straaten

Program Development - Jan van Straaten ------- Web design - Francis De Paemeleere
Supported by: servercare.nl