Notify of Played Item

General discussions.

Moderator: moderators

Notify of Played Item

Postby nutt318 » Wed Jan 04, 2012 4:59 pm

I was wondering if its possible to have Subsonic send an email when a movie/tv show is being played. Just would like to know when someone is using subsonic and my bandwidth. I know I can view this within the subsonic who is playing what but I'd rather it send me an email.

Anyways if anyone has any ideas I would appreciate it.

Thanks!
nutt318
 
Posts: 54
Joined: Thu Dec 09, 2010 9:24 pm

Re: Notify of Played Item

Postby ytechie » Tue Jan 10, 2012 10:40 am

I know how to get subsonic to trigger anything when a song is played, but I don't know off-hand how to send an email.

Your best bet is a php script. If you get a php script set up to send an email, we can get it working with subsonic in no time! :D
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Notify of Played Item

Postby nutt318 » Tue Jan 10, 2012 3:23 pm

Oh, well I've got a php script I've used in the past. Let me find it and I'll post the code here if you need it.
nutt318
 
Posts: 54
Joined: Thu Dec 09, 2010 9:24 pm

Re: Notify of Played Item

Postby ytechie » Tue Jan 10, 2012 9:52 pm

Is it hosted? I don't know how jetty handles php. :?

I know this may sound crazy, but if you can find a way to send an email by adding parameters to the url, (like a GET request), I could trigger it very very easily.
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Notify of Played Item

Postby nutt318 » Tue Jan 10, 2012 10:55 pm

I have it installed on my server at home. So I could use my ISP's smtp relay for sending messages as well.
nutt318
 
Posts: 54
Joined: Thu Dec 09, 2010 9:24 pm

Re: Notify of Played Item

Postby ytechie » Tue Jan 10, 2012 10:56 pm

How do you make the script work? Let's get this started!
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Notify of Played Item

Postby nutt318 » Thu Jan 12, 2012 10:08 pm

So how do you get it to trigger a .php file if a movie/tv show is played?

I've got 2 .php files that should do the trick.
nutt318
 
Posts: 54
Joined: Thu Dec 09, 2010 9:24 pm

Re: Notify of Played Item

Postby ytechie » Fri Jan 13, 2012 12:38 am

Well, you have to put the the trigger in the playAddDownload.jsp file if you only want it to trigger on movies/TV shows. Here is the part of that file that we will be editing:

Code: Select all
    <c:choose>
        <c:when test="${param.video}">
            <sub:url value="/videoPlayer.view" var="videoUrl">
                <sub:param name="path" value="${param.path}"/>
            </sub:url>
            <a href="${videoUrl}" target="main">
                <img src="<spring:theme code="playImage"/>" alt="<fmt:message key="common.play"/>" title="<fmt:message key="common.play"/>"></a>
        </c:when>
        <c:otherwise>
            <a href="javascript:noop()" onclick="top.playlist.onPlay('${path}');">
                <img src="<spring:theme code="playImage"/>" alt="<fmt:message key="common.play"/>" title="<fmt:message key="common.play"/>"></a>
        </c:otherwise>
    </c:choose>


More specifically,
Code: Select all
<a href="${videoUrl}" target="main">


Just write a javascript script at the top of the page, and insert the ol' "onclick='yourFunction()'.

That's all there is to it.

I actually have it running a script when a video is played. However, I have the script in the playlist.jsp file, so I just reference it using "onclick='top.playlist.myFunction()'".

Hope this helps!
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Notify of Played Item

Postby nutt318 » Mon Apr 30, 2012 6:45 pm

Ok, so back to this post again.

I'm not sure if I should use java script to send the email or have JavaScript call a .php file to send the email.

Also I'm not sure what file to actually edit and want to try and get this figured out.

Thanks!
nutt318
 
Posts: 54
Joined: Thu Dec 09, 2010 9:24 pm

Re: Notify of Played Item

Postby nutt318 » Mon Apr 30, 2012 8:50 pm

So I've got this and it sorta works except for it pops open my default mail client, anyone know of a way to have it send the email behind the scenes?

Also maybe include the video being watched along with the username of whos playing the content.

The code thats at the top of playAddDownload.jsp
Code: Select all
<script>
function sendMail() {
    var link = "mailto:me@example.com"
             + "&subject=" + escape("This is my subject")
             + "&body=" + escape("myText")
    ;

    window.location.href = link;
}
</script>


The code that is executed on the clicking of play
Code: Select all
<a href="${videoUrl}" target="main" onclick="sendMail()">
nutt318
 
Posts: 54
Joined: Thu Dec 09, 2010 9:24 pm

Re: Notify of Played Item

Postby ytechie » Tue May 01, 2012 1:33 am

Sending email behind the scenes was always sort of a mystery for me. In some languages it is easy to do (PHP), but in others, very hard.
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Notify of Played Item

Postby nutt318 » Tue May 01, 2012 3:32 pm

I've got a .php page loaded on my site that when you access it, it will send an email.

Do you know of a way to have a javascript function call or execute a webpage without it actually being displayed? If so then I think I can get it working. However I'm sure there is a better way to accomplish this. Or if I could put PHP code within the .jsp file, which I dont think is possible.
nutt318
 
Posts: 54
Joined: Thu Dec 09, 2010 9:24 pm

Re: Notify of Played Item

Postby nutt318 » Wed May 02, 2012 7:40 pm

Got it figured out thanks to some help of a co-worker of mine. Anyways I posted the how to in the tutorial section

viewtopic.php?f=6&t=9443
nutt318
 
Posts: 54
Joined: Thu Dec 09, 2010 9:24 pm


Return to General

Who is online

Users browsing this forum: No registered users and 7 guests