source: tools/xupnpd/xupnpd/src/plugins/staff/xupnpd_minaev.lua @ 34374

Last change on this file since 34374 was 34374, checked in by Stephan, 9 years ago

add xupnpd

File size: 2.4 KB
Line 
1-- Copyright (C) 2011-2012 Anton Burdinuk
2-- clark15b@gmail.com
3-- https://tsdemuxer.googlecode.com/svn/trunk/xupnpd
4
5-- feed: archive
6function minaev_updatefeed(feed,friendly_name)
7    local rc=false
8
9    local feed_url='http://www.minaevlive.ru/'..feed..'/'
10    local feed_name='minaev_'..string.gsub(feed,'/','_')
11    local feed_m3u_path=cfg.feeds_path..feed_name..'.m3u'
12    local tmp_m3u_path=cfg.tmp_path..feed_name..'.m3u'
13
14    local feed_data=http.download(feed_url)
15
16    if feed_data then
17        local dfd=io.open(tmp_m3u_path,'w+')
18        if dfd then
19            dfd:write('#EXTM3U name=\"',friendly_name or feed_name,'\" type=mp4 plugin=minaev\n')
20
21            local pattern=string.format('<h2>%%s*<a href="(/%s/%%w+/)">(.-)</a>%%s*</h2>',feed)
22
23            for u,name in string.gmatch(feed_data,pattern) do
24                local url=string.format('http://www.minaevlive.ru%s',u)
25                dfd:write('#EXTINF:0,',name,'\n',url,'\n')
26            end
27
28            dfd:close()
29
30            if util.md5(tmp_m3u_path)~=util.md5(feed_m3u_path) then
31                if os.execute(string.format('mv %s %s',tmp_m3u_path,feed_m3u_path))==0 then
32                    if cfg.debug>0 then print('MinaevLive feed \''..feed_name..'\' updated') end
33                    rc=true
34                end
35            else
36                util.unlink(tmp_m3u_path)
37            end
38        end
39
40        feed_data=nil
41    end
42
43    return rc
44end
45
46function minaev_sendurl(minaev_url,range)
47    local url=nil
48
49    if plugin_sendurl_from_cache(minaev_url,range) then return end
50
51    local clip_page=http.download(minaev_url)
52
53    if clip_page then
54--http://media.russia.ru/minaevlive/120/sd.mp4
55--http://media.russia.ru/minaevlive/120/hd720p.mp4
56        local u=string.match(clip_page,'.+<source src="(http://media.russia.ru/minaevlive/%w+/)%w+.mp4.+"')
57
58        if u then
59            url=u..'sd.mp4'
60        end
61    end
62
63    if url then
64        if cfg.debug>0 then print('MinaevLive Real URL: '..url) end
65
66        plugin_sendurl(minaev_url,url,range)
67    else
68        if cfg.debug>0 then print('MinaevLive clip is not found') end
69
70        plugin_sendfile('www/corrupted.mp4')
71    end
72end
73
74plugins['minaev']={}
75plugins.minaev.name="MinaevLive"
76plugins.minaev.desc="archive"
77plugins.minaev.sendurl=minaev_sendurl
78plugins.minaev.updatefeed=minaev_updatefeed
79
80--minaev_updatefeed('archive')
81--minaev_sendurl('http://www.minaevlive.ru/archive/link5bd88f9b/','')
Note: See TracBrowser for help on using the repository browser.