Return Strict Amount - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: Return Strict Amount (/showthread.php?tid=135914) |
Return Strict Amount - mikey1234 - 2012-07-12 how can i return like only 12 items instead of the lot Code: url = 'http://deturl.com/www.youtube.com/results?search_query=adele+karaoke' RE: Return Strict Amount - oneadvent - 2012-07-12 Do you need to limit the search or the for statement? For instance is it ok for match1 to obtain all matches if the for loop only deals with the first 12? If it was a limit on the for statement you could just add a counter, ie: Code: nums = {1,2,3,4,5,6,7,8,9,10,11,12} #mock match1 list RE: Return Strict Amount - mikey1234 - 2012-07-12 i changed the code in first post to show all code basically when people do a search match spits out about 25 to 30 but takes forever so i only want it to return about 12 RE: Return Strict Amount - oneadvent - 2012-07-12 Looks to me like this is the slow one: Code: match1 = re.compile('property="og:title" content="(.+?)"/>\r\n<meta').findall(link) Code: match=re.compile('src="http://i1.ytimg.com/vi/(.+?)/1.jpg').findall(link) Code: url = 'http://deturl.com/www.youtube.com/results?search_query=adele+karaoke' Suppose it is "sloppy" but I do not see a way to limit re matches via the re command. RE: Return Strict Amount - mikey1234 - 2012-07-12 lol not sloppy..... but match still returns 24 and match1 only returns 1 match is actually pretty quick but match1 uses the url from match and scrapes a different website 24 times to get name RE: Return Strict Amount - oneadvent - 2012-07-12 hmmm gotta be a typo. Yea it is ok for match to have 24, and like you are saying match1 is the slow poke because of all the websites. Thats why we want it to stop after 12... Really has to be a typo somewhere....either with me or you? Wanna repaste the code? Oh and "if i > 11:" realy should be "if i>=11:" RE: Return Strict Amount - oneadvent - 2012-07-12 OK I ran this: Code: # This test program is for finding the correct Regular expressions on a page to insert into the plugin template. and I get the result: Code: ['TGVhQ61C6IU', 'sTE9s43rdT8', 'v5pJMwgKQcw', 'XUQVk4oG8LM', 'x-nTWktLBL8', 'Cgdes6lFjzM', 'vWaXO1wnOKU', 'L7nmEjjrKGc', 'fgfJLw9Zug4', '1l0drm-lM5M', 'uqhVqsPI5v8', 'KMOmkQ_LhYA', 'AX-kWqAwH1I', 'HHL0q-z7CyM', '59CPfYsIKc4', '2QC8DfcSe_0', 'SFRJpyNQ1K0', '3lrBve6xLw8', 'MgEyI3EFPP4', '_4fNgNCxQWk', '7D26e6l_5iI', 'JFwd16raBKU', 'LrW7Umr_5wM', 'SRn4Fh47kok', 'li9W-yEjK2g', 'uQCaVs5FGpc', '3bxsKcbKVa0', 'buG0HCAFy3s', '2AHVUH_bGBY', 'LtMb_fGHUY0', '4W5TO-woLmg', '0jF6XyW3QY4'] So it is definitely limiting, the two blanks were removed btw, might want to check for those before adding a 1 to i. RE: Return Strict Amount - mikey1234 - 2012-07-12 thats brilliant thank you you a star |