Sign up here and you can log into the forum!

FirstRow Sports Plugin Development

Discussion, features, plugins--everything about zoster's UMSP UPnP Media Server software

FirstRow Sports Plugin Development   

Postby Gui » Tue Mar 06, 2012 9:41 am

FirstRow Sports

Website: http://www.firstrowsports.eu/

lua script already done for PlayOn:

Code: Select all
    ---------------------------------------------------------------------------------------------------------------------
    -- FirstRow                                                                             
    -- By Microzoa (c) 2011
    -- Version 1.0.9
    ---------------------------------------------------------------------------------------------------------------------
    --[[Settings
       name = "FirstRow";
       description = "Sports & Tv Streamed";
       version = "1.0.9";
       apiversion = "1";
    EndSettings]]--

    --[[Update
       local currentVersion = 109;
       local siteVersion = GetURL("https://sites.google.com/site/microzoa/firstrow");
       siteVersion = str_get_between(siteVersion, 'Script Version: ', '<br />', 0)
       siteVersion = str_replace(siteVersion, ".", "")

       if tonumber(siteversion) > currentVersion then
             return 'https://sites.google.com/site/microzoa/firstrow/FirstRow.lua';
       end;

       return nil;
    EndUpdate]]--

    ------------------------------------------------------------Automatic Update Code--------------------------------------
    local versionCheck = GetURL("https://sites.google.com/site/microzoa/firstrow")

    if versionCheck ~= "<error>" then
       local scriptVersionLocal = 109
       local scriptVersionSite = str_get_between(versionCheck, 'Script Version: ', '<br />', 0)
          scriptVersionSite = tonumber(str_replace(scriptVersionSite, ".", ""))
       if scriptVersionSite > scriptVersionLocal then
          local saveScript = DownloadAndSaveFile("https://sites.google.com/site/microzoa/firstrow/FirstRow.lua", GetCurrentPath() .. "\\Scripts\\FirstRow.lua");
          local newScriptCode = OpenFile(GetCurrentPath() .. "\\Scripts\\FirstRow.lua");
          ShowMsg('**"FirstRow" has automatically updated to version '..scriptVersionSite..'**')
          RunScript(newScriptCode)

          return nil
       end;
    end;
    ---------------------------------------------------------------------------------------------------------------------

    --[[Director
    function director:GetPlayerViewingRectangle(playerSize)
       return Rectangle(0, 0, playerSize.Width, playerSize.Height - 0)
    end
    EndDirector]]--

    -----------------------------------------------------------------------------------------------------------------------
    -- Misc Functions

    function titlecase(change)                        --I did not write this function, It was written by
       local buf = {}                           --Mark Edgar at lua-users.org
          for word in string.gfind(change, "%S+") do            --http://lua-users.org/wiki/SciteTitleCase
             local first, rest = string.sub(word, 1, 1), string.sub(word, 2)
             table.insert(buf, string.upper(first) .. string.lower(rest))
          end
       return table.concat(buf, " ")
    end



    function localizeTime(UTCtime)
        UTCsplittime = _sp(UTCtime, ":")


       -- Compute the difference in seconds between local time and UTC. Refer http://lua-users.org/wiki/TimeZone
       local function get_timezone()
            local now = os.time()
            return os.difftime(now, os.time(os.date("!*t", now)))
       end
       timezoneDiff = get_timezone()

       local localTimeInSeconds = os.time{year=os.date("!%Y"), month=os.date("!%m"), day=os.date("!%d"), hour=UTCsplittime[1], min=UTCsplittime[2]} + timezoneDiff

       local myTime = os.date("%H,%M", localTimeInSeconds); _l(myTime)
          myTime = str_split(myTime, ",")
          myTime = myTime[1] ..":" ..myTime[2]     
       return myTime
    end


    -----------------------------------------------------------------------------------------------------------------------
    base = "http://www.firstrowsports.eu/"
    -----------------------------------------------------------------------------------------------------------------------
    function menu()
       _vf("Football", "sportPage|" .."sport/football.html")
       _vf("Am. football", "sportPage|" .."sport/american-football.html")
       _vf("Basketball", "sportPage|" .."sport/basketball.html")
       _vf("Ice Hockey", "sportPage|" .."sport/ice-hockey.html")
       _vf("Baseball", "sportPage|" .."sport/baseball.html")
       _vf("Boxing-WWE-UFC", "sportPage|" .."sport/boxing-wwe-ufc.html")
       _vf("Tennis", "sportPage|" .."sport/tennis.html")
       _vf("Motosport", "sportPage|" .."sport/motosport.html")
       _vf("Rugby", "sportPage|" .."sport/rugby.html")
       _vf("Darts", "sportPage|" .."sport/darts.html")
       _vf("Snooker", "sportPage|" .."sport/snooker.html")
       _vf("Golf", "sportPage|" .."sport/golf.html")
       _vf("Aussie Rules", "sportPage|" .."sport/aussie-rules.html")
       _vf("Handball", "sportPage|" .."sport/handball.html")
       _vf("Others", "sportPage|" .."sport/others.html")
       _vf("TV", "sportPage|" .."sport/tv-box.html")

    end;
    -----------------------------------------------------------------------------------------------------------------------
    function fr_Resolve(url)
       --_l("URL: " ..url)
       _SPECIAL_resolve_xml = '<media><url type="flash">'..str_html_encode(url)..'</url><options><AudioAbortInterval>30</AudioAbortInterval><VideoAbortInterval>300000</VideoAbortInterval></options></media>'
    end

    function sportPage(URLsport)
       local HTML = GetURL(base .. URLsport); _l("sportPage: " .. base .. URLsport)
       local section = str_get_between(HTML, '<div id="accordion">', 'id="footer"', 0)

       local data = {"", 0, 0 }
       
       while section do

          data = str_get_between_a(section, '<img class="chimg" alt="', '"', data[3] + 1)
             if not data then break; end;
          local channelTitle = str_trim(data[1])

          data = str_get_between_a(section, '<span', '</span>', data[3] + 1)
             if not data then break; end;
          local matchTime_a = str_trim(data[1])
          local matchTime_b = str_replace(matchTime_a, '&nbsp;',"")
          local matchTime_c = str_replace(matchTime_b, string.match(matchTime_b, "%s+"),"")
          local matchTime_d = str_replace(matchTime_c, '<span class="matchtime">',"")
          local matchTime_e = str_replace(matchTime_d, '>',"")
         
         
          -- UTC to local timezone funkiness --

         
          local localTime = localizeTime(matchTime_e)
          --_l("localTime:" ..localTime)

          _vf(localTime .." - " ..channelTitle, "matchLinks|" ..URLsport .."|" ..channelTitle)

       end;

    end;

    function matchLinks(URLsport2, channelTitle2)
       local HTML = GetURL(base .. URLsport2); --_l("matchLinks: " .. base .. URLsport2 ..channelTitle2); --_l(HTML)
       local section = str_get_between(HTML, channelTitle2, '</div>', 0); --_l("matchLinks section: " ..section)

       local data = {"", 0, 0 }
       
       while section do

          data = str_get_between_a(section, "target='_blank' title='", "'", data[3] + 1)
             if not data then break; end;
          local linklongTitle = str_trim(data[1]); --_l("linklongTitle: "..linklongTitle)

          data = str_get_between_a(section, "href='", "'", data[3] + 1)
             if not data then break; end;
          local linkLink = str_trim(data[1]); --_l("linkLink: "..linkLink)

          data = str_get_between_a(section, ">", "<", data[3] + 1)
             if not data then break; end;
          local linkTitle_a = str_trim(data[1]); --_l("linkTitle: "..linkTitle_a)
          local linkTitle = titlecase(linkTitle_a)

          if linkTitle ~= '' then
             _vr(linkTitle, 'code:fr_Resolve("'..base ..linkLink..'")', linklongTitle, '', ConvertTime("3:00:00"))
          end;
       end;

    end;





    menu();

    --[[Image
    /9j/4AAQSkZJRgABAQAAAQABAAD//gA7Q1JFQVRPUjogZ2QtanBlZyB2MS4wICh1c2luZyBJSkcgSlBFRyB2NjIpLCBxdWFsaXR5ID0gNzUK/9sAQwAIBgYHBgUIBwcHCQkICgwUDQwLCwwZEhMPFB0aHx4dGhwcICQuJyAiLCMcHCg3KSwwMTQ0NB8nOT04MjwuMzQy/9sAQwEJCQkMCwwYDQ0YMiEcITIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIy/8AAEQgAEQBAAwEiAAIRAQMRAf/EAB8AAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKC//EALUQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+v/EAB8BAAMBAQEBAQEBAQEAAAAAAAABAgMEBQYHCAkKC//EALURAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/aAAwDAQACEQMRAD8A8606yOoXqW4LgFWYmNN7YVSxwOMnAqw2i3UpQWltdyliVIeHaQRx6nuGH4VShuHgjnRAv75PLYkcgbg3H/fI/DNWX1a6ZIYwVSOJkYIo+VmVQoJB68D6cn1NAE1voN98ktzZXaW7llR1jPzuBwoPucDPPXjOKgvdNmtQJRFJ5DAYZh0JGcEj8R+B9wEn1W8uA4kkGG67VC/xbj075A568CrP/CR6mHZ45kikdFRnjiUMwGMfNjPb19R0oAig0a6miuHOI2g+8jA7umegFNOi6gGVfs5yf9tcdupzx1H51Emo3aGUidt0pJdjgsSepyeeasS65fSS71kWPjG1FG3oOx6ngflXLL6ypvltbzOOf1pTfJa3ncami3z4zEqAgnLuB0znv7Gqs9rNa7POTb5i7l+YHI9eKl/tK88yOQzZeNSqkqOh6g8c9T1qOe6nuVjWV9yxjCDAGB+FXD2/N79rfP8ArsaQ+sc3v2t5X8/+AQd6KKK3OgKKKKACiiigAooooA//2Q==
    EndImage]]--


XBMC SportsDevil Plugin with FirstRow : http://xbmc-development-with-passion.googlecode.com/svn/branches/repo/plugin.video.SportsDevil/

noname has already implemented the (category and show selection) part:

Code: Select all
    <?php


       function _pluginMain($prmQuery) {

          parse_str($prmQuery, $queryData);
          $items = array();

          if(isset($queryData['show']) && $queryData['show']!=""){

             $html = file_get_contents('http://www.firstrowsports.eu/'.urldecode($queryData['show']));

             # TODO: fetch rtmp url

             return $items;

          }

          if(isset($queryData['cat']) && $queryData['cat']!=""){

             $html = file_get_contents('http://www.firstrowsports.eu/'.urldecode($queryData['cat']));

             preg_match_all("/<h3>\s*<a class=\"accordlink\"\s+href=\'\/(watch[^\']*)\'.*?src=\"([^\"]*)\".*?<\/span>\s*(.*?)\s*<\/a>\s*<\/h3>/i", $html, $shows, PREG_SET_ORDER);

             foreach ($shows as $show){
                $show[3] = preg_replace("/\s*<[^>]*>\s*/", '', $show[3]);
                $items[] = array(
                   'dc:title'        => $show[3],
                   'id'              => 'umsp://plugins/firstrowsports?show='.urlencode($show[1]),
                   'upnp:album_art'  => $show[2],
                   'upnp:class'      => 'object.container',
                );
             }

             return $items;

          }

          $cats = array(
             'Football   sport/football.html   1',
             'Am. football   sport/american-football.html   3',
             'Basketball   sport/basketball.html   2',
             'Ice Hockey   sport/ice-hockey.html   4',
             'Baseball   sport/baseball.html   5',
             'Boxing-WWE-UFC   sport/boxing-wwe-ufc.html   7',
             'Tennis   sport/tennis.html   6',
             'Motosport   sport/motosport.html   10',
             'Rugby   sport/rugby.html   8',
             'Darts   sport/darts.html   11',
             'Snooker   sport/snooker.html   11',
             'Golf   sport/golf.html   13',
             'Aussie Rules   sport/aussie-rules.htm   11',
             'Handball   sport/handball.html   11',
             'Others   sport/others.html   11',
             'TV   sport/tv-box.html   16',
          );

          foreach($cats as $cat) {
             $cat = explode("\t", $cat);
             $items[] = array(
                'id'              => 'umsp://plugins/firstrowsports?cat='.urlencode($cat[1]),
                'dc:title'        => $cat[0],
                'upnp:class'      => 'object.container',
                'upnp:album_art'  => 'http://cssfiles.firstrowsports.eu/images/sports/'.$cat[2].'.png',
             );
          }

          return $items;

       }

    ?>



- firstrowsports.eu doesn't host videos and only links to different rtmp video streamming servers like http://www.castto.me

Anyone accept to continue this challenge? I believe this is a TOP wanted plugin.
User avatar
Gui
Developer
 
Posts: 161
Joined: Wed Jan 11, 2012 4:19 pm
Location: Hellgarve

Re: FirstRow Sports Plugin Development   

Postby Gui » Wed Mar 21, 2012 5:08 am

Working on it...or at least trying if i came up with something stable i let you know.
User avatar
Gui
Developer
 
Posts: 161
Joined: Wed Jan 11, 2012 4:19 pm
Location: Hellgarve

Re: FirstRow Sports Plugin Development   

Postby d3vil » Wed Apr 10, 2013 2:04 am

Any news about this?
d3vil
WDTVer
 
Posts: 38
Joined: Mon Apr 12, 2010 3:43 am

Re: FirstRow Sports Plugin Development   

Postby brotato » Mon Apr 22, 2013 11:05 am

this would be amazing but i can see why it never came to be. your best bet is something like serviio and maybe even a premium streaming service like live247tv, all their links can be inserted into serviio through the rtmp process but they must be on the fly transcoded so the wdtv is able to play them.
brotato
DLX'er
 
Posts: 122
Joined: Mon Mar 19, 2012 4:03 pm

Re: FirstRow Sports Plugin Development   

Postby Gui » Tue Apr 23, 2013 2:57 am

This thread was created when i still dream about live stream...like brotato said your best bet is probably serviio.
User avatar
Gui
Developer
 
Posts: 161
Joined: Wed Jan 11, 2012 4:19 pm
Location: Hellgarve


Return to UMSP Media Server

Who is online

Users browsing this forum: No registered users and 0 guests