Recent Changes - Search:

LiveStreamsPro

PmWiki

pmwiki.org

edit SideBar

Cookies & Sessions

Sessions can be created from a regex and saved into a cookie file. The cookie jar can be reopened to persist sessions. +++ Cookies can also be appended to the link url and read in <regex> using <includeheaders>. +++ Cookies can be set in <regex> using <setcookie>MyCookie=MyCookieValue;</setcookie>

There are some sites which stops you login in multi time until the last session expires. This means, for every video that you play, you can't login->get url->play Url etc. You either would need to logout via regex at the end of the video play or keep the session so second video or so on use that same session.

To save the session, you have save cookieJar method.
Example:

<regex>
 <name>savecookie</name>
 <expres></expres>
 <page></page>
 <cookieJar>save[siteName.lwp]</cookieJar>
</regex>

Afterwards for the second or third video, you have open the cookie Jar.
Example:
<regex>
 <name>LoadCookie</name>
 <expres></expres>
 <page>http://www.MySite.com/</page>
 <cookieJar>open[siteName.lwp]</cookieJar>
 <ignorecache/>
</regex>


You could call these regex right after the login to save the cookie and in the begining of second video to load the cookie. It would be better to create an entry to login into perticular site, which does nothing but login and save cookie. and rest of entries from that site should load the cookie and get the page that you want to load.

NOTE: I am not providing login code as its different to different sites and you should be able to perform that step ,otherwise you dont need these functions. Use different name for lwp file for each site., dont share these are it would overrite the cookies.



Example to send cookie in link:

<item>
    <title>live stream test</title>
    <link>$doregex[get-page]$doregex[get-initsesion]|Cookie=$get_cookies$&amp;User-Agent=AppleCoreMedia/1.0.0.11B554a (iPhone; U; CPU OS 7_0_4 like Mac OS X; en_gb)&amp;X-Playback-Session-Id=$GUID$</link>
    <regex>
        <name>get-initsesion</name>
        <expres></expres>
        <page>$doregex[get-page]</page>
        <agent>AppleCoreMedia/1.0.0.11B554a (iPhone; U; CPU OS 7_0_4 like Mac OS X; en_gb)</agent>
        <cookieJar></cookieJar>
    </regex>
    <regex>
        <name>get-page</name>
        <expres>"m3u8_url":"(.*?)"</expres>
        <page>http://new.livestream.com/popsugar/live</page>
        <agent>Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53</agent>
        <cookieJar></cookieJar>
    </regex>
</item>
 



How to do login only once and save session cookie for reuse by play items:

  1. load the cookies (if there is none then there will be blank), then find if the default page has login prompts or not, if not, run the login regex else continue and then save the cookies.
  2. create an item which only does the login and save the cookiejar. All others should just load the cookies and play.

Option 1 would be python code like:

<link>$doregex[loadcookie]$doregex[LoginWithCheck]$doregex[PlayMedia]$doregex[savecookie]</link>
\\
\\
<regex>
<name>LoginWithCheck</name>
<expres><![CDATA[#$pyFunction
def GetLSProData(page_data,Cookie_Jar,m):
import re
import requests
## find in the page_data if we have login prompts if so, make a requests and post to the page with login
return ''
]]></expres>
<page>http://mainpageOfSite.com/</page>
<cookieJar></cookieJar>
</regex>


Cookies are normally generated via login. setcookie does work but you will have to keep changing the data. You can call a regex from <cookiejar>, there were quite a few example already posted but here is another one (this will not work as i have removed login details).
See when it get to call channelinfo, it creating the session by logging onto the website <cookieJar>$doregex[LoginAndCookies]</cookieJar> means run the regex and use it session/cookies. The login regex normally don't return anything as its just the login process.

So Option 2 could look like this:
<item>
<title>test login</title>
<link>$doregex[get-ClreanURL]</link>
<repeat>10</repeat>
<regex>
<name>get-ClreanURL</name>
<expres>$pyFunction:'$doregex[get-url]'.replace('\\/','/')</expres>
<page></page>
</regex>

<regex>
<name>get-url</name>
<expres>low","url":"(.*?)"</expres>
<page>http://www.filmon.com/ajax/getChannelInfo</page>
<referer>http://www.filmon.com/tv/hrtv</referer>
<rawpost>channel_id=694&amp;quality=low</rawpost>
<agent>Mozilla/5.0 (Windows NT 6.2; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0</agent>
<x-req>XMLHttpRequest</x-req>
<cookieJar>$doregex[LoginAndCookies]</cookieJar>
</regex>

<regex>
<name>LoginAndCookies</name>
<expres></expres>
<page>http://www.filmon.com/ajax/login?return_url=/</page>
<referer>http://www.filmon.com/</referer>
<rawpost>email=emailaddress%40yahoo.com&amp;password=mypassword&amp;remember=1&amp;signin=Log+in</rawpost>
<agent>Mozilla/5.0 (Windows NT 6.2; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0</agent>
<x-req>XMLHttpRequest</x-req>
<cookieJar></cookieJar>
</regex>
</item>

Edit - History - Print - Recent Changes - Search
Page last modified on June 03, 2016, at 02:58 PM