-------- xpety 02 05 2017 function xpety_updatefeed(feed,friendly_name) local max_pages=5 local rc = false local host = 'http://xpety.com/' local feed_url = nil local feed_name = "xpety" if feed:find("categories") then feed_name = feed_name .. "_" .. feed:match('categories/(.-)$') feed_url = 'show/' .. feed .. "/" end if feed_url == nil then feed_url = 'show/newvideo/' end local data = "" for j = 1 , max_pages do local tmp = http.download(host .. feed_url .. j) if tmp then data = data .. tmp end end local feed_m3u_path=cfg.feeds_path .. feed_name .. '.m3u' local tmp_m3u_path=cfg.tmp_path .. feed_name ..'.m3u' local dfd=io.open(tmp_m3u_path,'w+') if dfd and data then dfd:write('#EXTM3U name=\"',friendly_name or feed_name,'\" type=mp4 plugin=xpety\n') local n=0 if data then for item in data:gmatch('') do local url=item:match('href="(.-)"') local logo= item:match('data%-original="(.-)"') local title= item:match('title">(.-)<') if logo and logo:sub(1, 2) == '//' then logo = "https:" .. logo end if #logo+#title > 235 then if #logo < 235 then local shorttitle = logo .. title title =shorttitle:sub(#logo+1, 235) else title = n .. " : to long title" end end dfd:write('#EXTINF:0 logo=',logo,' ,',title,'\n',url,'\n') n=n+1 data=nil end end dfd:close() end if util.md5(tmp_m3u_path)~=util.md5(feed_m3u_path) then if os.rename(tmp_m3u_path, feed_m3u_path) then rc=true if cfg.debug>0 then print('XPETY feed \''..feed_name..'\' updated') end end end util.unlink(tmp_m3u_path) return rc end function xpety_sendurl(xpety_url,range) local host = 'http://xpety.com/' local data,location=http.download(host .. xpety_url) if location then data=http.download(location) end if data then local video_url = nil local data = data:match('') for item in data:gmatch('') do local videourl = item:match('src="(.-)"') if videourl then video_url = videourl end end if video_url then plugin_sendurl(video_url,video_url,range) else plugin_sendfile('www/corrupted.mp4') end end end plugins['xpety']={} plugins.xpety.name="XPETY" plugins.xpety.sendurl=xpety_sendurl plugins.xpety.updatefeed=xpety_updatefeed plugins.xpety.getvideourl=xpety_get_video_url -- xpety_updatefeed('xpety', 'home_xpety')