It is currently September 23rd, 2020, 5:32 pm

Edge Suite [Beta 0.8]

Post your work-in-progress and completed skins to share and discuss.
User avatar
jsmorley
Developer
Posts: 21386
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Edge Suite [Public Beta 0.66]

Post by jsmorley »

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.
User avatar
jsmorley
Developer
Posts: 21386
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Edge Suite [Public Beta 0.66]

Post by jsmorley »

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

inputString = '<item>One</item><item>Two></item><item>Three</item>'
dummyString, itemCount = string.gsub(inputString, '<item>', '')
print(itemCount)
Prints "3" in this case.
User avatar
Mordasius
Posts: 1077
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Edge Suite [Public Beta 0.66]

Post by Mordasius »

jsmorley 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.
This is precisely what you have in line 58 of your .lua file

Code: Select all

sRawCounted, iNumberOfItems = string.gsub(sRaw, '<entry', "")
The value of iNumberOfItems shows how many videos there are.

This is why I suggested using for i = 1, iNumberOfItems do rather than for i = 1, 18 do when the database is created.
User avatar
KreAch3R
Posts: 629
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Edge Suite [Public Beta 0.66]

Post by KreAch3R »

@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?
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
jsmorley
Developer
Posts: 21386
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Edge Suite [Public Beta 0.66]

Post by jsmorley »

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?
User avatar
KreAch3R
Posts: 629
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Edge Suite [Public Beta 0.66]

Post by KreAch3R »

jsmorley wrote:Can you do me a favor and post this in Bugs and Feature Suggestions, so the whole team can get at it?
Of course. Done.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
Mordasius
Posts: 1077
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Edge Suite [Public Beta 0.66]

Post by Mordasius »

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.
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.

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  
A couple of changes to use iNumberOfItems in FeedOutput then fixes the scrolling with less than 18 images.

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()
I subscribed to a couple of news channels and there don't appear to be any problems when there are > 18 images.
User avatar
KreAch3R
Posts: 629
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Edge Suite [Public Beta 0.66]

Post by KreAch3R »

Wow. I am so thankful. Your code works well in > 18 images, too. I added this part in FeedOutput:

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
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!
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
Mordasius
Posts: 1077
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: Edge Suite [Public Beta 0.66]

Post by Mordasius »

KreAch3R wrote: I added this part in FeedOutput:.. To make it cycle when it reached the bottom items.
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.

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! :)
User avatar
KreAch3R
Posts: 629
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Edge Suite [Public Beta 0.66]

Post by KreAch3R »

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
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image