You may have already tumbled to this, but you can get a count of items in a string you are about to parse with string.gsub() which is generally used to "search and replace" in a string, but has the additional benefit of returning how many items it "replaced" as a second value.
inputString = '<item>One</item><item>Two></item><item>Three</item>'
dummyString, itemCount = string.gsub(inputString, '<item>', '')
print(itemCount)
Prints "3" in this case.
It is currently December 5th, 2023, 6:43 am
Edge Suite [Beta 0.8]
-
- Developer
- Posts: 22593
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
-
- Developer
- Posts: 22593
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Edge Suite [Public Beta 0.66]
You may have already tumbled to this, but you can get a count of items in a string you are about to parse with string.gsub() which is generally used to "search and replace" in a string, but has the additional benefit of returning how many items it "replaced" as a second value.
Prints "3" in this case.
Code: Select all
inputString = '<item>One</item><item>Two></item><item>Three</item>'
dummyString, itemCount = string.gsub(inputString, '<item>', '')
print(itemCount)
-
- Posts: 1127
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: Edge Suite [Public Beta 0.66]
This is precisely what you have in line 58 of your .lua filejsmorley wrote:You may have already tumbled to this, but you can get a count of items in a string you are about to parse with string.gsub() which is generally used to "search and replace" in a string, but has the additional benefit of returning how many items it "replaced" as a second value.
Code: Select all
sRawCounted, iNumberOfItems = string.gsub(sRaw, '<entry', "")
This is why I suggested using for i = 1, iNumberOfItems do rather than for i = 1, 18 do when the database is created.
-
- Posts: 608
- Joined: February 7th, 2011, 7:27 pm
- Location: Thessaloniki, GR
Re: Edge Suite [Public Beta 0.66]
@Mordasius, I really like your affection to test skins that much. Feel free to tear mine up. 
As for the NumberOfItems: I completely get what you both are saying. I had noticed the brilliant way of replacing something just to get the number of replacements. The problem lies in the fact that not all the meter values are provided by Lua, but also from the separate Webparser measure used for images only (didn't find a way to download them through Lua), which, I guess, would require a lookahead assertion to successfully parse <18 images. Besides that, the scroller plugin is hardcoded to cycle between 1 and 16 (to display 18 videos, the 2 last can't be reached, but they exist only for aesthetic reasons), and I don't know if it supports DynamicVariables (to make the change based on NumberOfItems).
Lastly, I replaced the for i = 1, iNumberOfItems do to for i = 1, 18 do because I thought that doing that loop for more items that the ones displayed would be CPU redundant. The feeds I tested always had >18 items (20 ~ 21).
The bottom line is, that I would have to dig deep into the skin, to find out if your logical suggestion is possible. That's why it is a little lower on my list, than solving frequent recurring bugs first.
That said, how did you find my suite in general?
@JSMorley, did you received my PM?

As for the NumberOfItems: I completely get what you both are saying. I had noticed the brilliant way of replacing something just to get the number of replacements. The problem lies in the fact that not all the meter values are provided by Lua, but also from the separate Webparser measure used for images only (didn't find a way to download them through Lua), which, I guess, would require a lookahead assertion to successfully parse <18 images. Besides that, the scroller plugin is hardcoded to cycle between 1 and 16 (to display 18 videos, the 2 last can't be reached, but they exist only for aesthetic reasons), and I don't know if it supports DynamicVariables (to make the change based on NumberOfItems).
Lastly, I replaced the for i = 1, iNumberOfItems do to for i = 1, 18 do because I thought that doing that loop for more items that the ones displayed would be CPU redundant. The feeds I tested always had >18 items (20 ~ 21).
The bottom line is, that I would have to dig deep into the skin, to find out if your logical suggestion is possible. That's why it is a little lower on my list, than solving frequent recurring bugs first.
That said, how did you find my suite in general?

-
- Developer
- Posts: 22593
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Edge Suite [Public Beta 0.66]
I did get your PM. Just forwarded a copy to a couple of others so we can look at it.
Can you do me a favor and post this in Bugs and Feature Suggestions, so the whole team can get at it?
Can you do me a favor and post this in Bugs and Feature Suggestions, so the whole team can get at it?
-
- Posts: 608
- Joined: February 7th, 2011, 7:27 pm
- Location: Thessaloniki, GR
Re: Edge Suite [Public Beta 0.66]
Of course. Done.jsmorley wrote:Can you do me a favor and post this in Bugs and Feature Suggestions, so the whole team can get at it?
-
- Posts: 1127
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: Edge Suite [Public Beta 0.66]
You were right about that. Changing ThumbGET to ThumbGET=(?(?=.*src).*src="(.*)".*src=.*src=.*src=.*src=.*src=.*) avoids the WebParser errors if there are less than 18 images.KreAch3R wrote:The problem lies in the fact that not all the meter values are provided by Lua, but also from the separate Webparser measure used for images only, which, I guess, would require a lookahead assertion to successfully parse <18 images.
Fortunately, the Scroller Plugin accepts dynamic variables so you can use MaxValue=#NumberOfThumbs# in [mScroller] and set NumberOfThumbs in the lua function CreateData.
Code: Select all
function CreateData(sRaw)
tTitles = {}
tAuthors = {}
tLinks = {}
-- CREATE DATABASE
iInit = 0
if iNumberOfItems>18 then iNumberOfItems=18 end
SKIN:Bang('!SetVariable', 'NumberOfThumbs', iNumberOfItems)
for i = 1, iNumberOfItems do
iItemStart, iItemEnd = string.find(sRaw, sPatternItem, iInit)
sItem = string.sub(sRaw, iItemStart, iItemEnd)
tTitles[i] = string.match(sItem, sPatternItemTitle)
tTitles[i] = ParseSpecialCharacters(tTitles[i])
tLinks[i] = string.match(sItem, sPatternItemLink)
tLinks[i] = ParseSpecialCharacters(tLinks[i])
tAuthors[i] = string.match(sItem, sPatternItemAuthor)
tAuthors[i] = ParseSpecialCharacters(tAuthors[i])
iInit = iItemEnd + 1
end
end
Code: Select all
function FeedOutput()
-- OUTPUT
iScroll = msScroll:GetValue()
if iScroll ~= 1 then
SKIN:Bang('!EnableMeasure ReturnCounter')
end
iScrollEnd = iScroll + 2
if iScrollEnd>iNumberOfItems then iScrollEnd=iNumberOfItems end
j = 1
for i = iScroll, iScrollEnd do
SKIN:Bang('!SetOption "VideoCreator'..j..'" "Text" "'..tAuthors[i]..'"')
SKIN:Bang('!SetOption "VideoTitle'..j..'" "Text" "'..tTitles[i]..'"')
SKIN:Bang('!SetOptionGroup "Video'..j..'" "LeftMouseUpAction" "'..tLinks[i]..'"')
SKIN:Bang('!SetOption Thumbnail'..j..' MeasureName mThumbNail'..i..'')
j = j + 1
end
SKIN:Bang('!SetOption', 'VideoNumber', 'Text', iScroll..'/'..iNumberOfItems)
end --function FeedOutput()
-
- Posts: 608
- Joined: February 7th, 2011, 7:27 pm
- Location: Thessaloniki, GR
Re: Edge Suite [Public Beta 0.66]
Wow. I am so thankful. Your code works well in > 18 images, too. I added this part in FeedOutput:
To make it cycle when it reached the bottom items. I wanted to do it someday, but your changes made it easier to happen. Please test it with your feed, and thank you very much Mordasius!
Code: Select all
iScrollEnd = iScroll + 2
if iScrollEnd>iNumberOfItems then iScrollEnd=iNumberOfItems+2 end
j = 1
for i = iScroll, iScrollEnd do
-- cycle to the beginning
if i == iNumberOfItems + 1 then
i = 1
elseif i == iNumberOfItems + 2 then
i = 2
end
SKIN:Bang('!SetOption "VideoCreator'..j..'" "Text" "'..tAuthors[i]..'"')
SKIN:Bang('!SetOption "VideoTitle'..j..'" "Text" "'..tTitles[i]..'"')
SKIN:Bang('!SetOptionGroup "Video'..j..'" "LeftMouseUpAction" "'..tLinks[i]..'"')
SKIN:Bang('!SetOption Thumbnail'..j..' MeasureName mThumbNail'..i..'')
j = j + 1
end
-
- Posts: 1127
- Joined: January 22nd, 2011, 4:23 pm
- Location: GMT +8
Re: Edge Suite [Public Beta 0.66]
Yes that certainly makes the scrolling a lot better when you get to the bottom of the list. Unfortunately, the lua script crashes if you only have 1 or 2 new videos.KreAch3R wrote: I added this part in FeedOutput:.. To make it cycle when it reached the bottom items.
But hey, I don't suppose the sort of person with only 1 or 2 new videos in all their subscriptions will want to have the YouTube skin on their desktop in the first place!

-
- Posts: 608
- Joined: February 7th, 2011, 7:27 pm
- Location: Thessaloniki, GR
Re: Edge Suite [Public Beta 0.66]
Hah, probably not! :P But so that we can be certain, could you test this change here, because I can't get my hands in a feed with 2 videos.
Code: Select all
iInit = 0
if iNumberOfItems>18 then iNumberOfItems=18 end
if iNumberOfItems<3 then print('Not enough videos in your feed.') return end
SKIN:Bang('!SetVariable', 'NumberOfThumbs', iNumberOfItems)
for i = 1, 18 do
iItemStart, iItemEnd = string.find(sRaw, sPatternItem, iInit)
sItem = string.sub(sRaw, iItemStart, iItemEnd)
tTitles[i] = string.match(sItem, sPatternItemTitle)
tTitles[i] = ParseSpecialCharacters(tTitles[i])
tLinks[i] = string.match(sItem, sPatternItemLink)
tLinks[i] = ParseSpecialCharacters(tLinks[i])
tAuthors[i] = string.match(sItem, sPatternItemAuthor)
tAuthors[i] = ParseSpecialCharacters(tAuthors[i])
iInit = iItemEnd + 1
end