Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Library statistics in footer #61

Open
oskameDEV opened this issue Dec 2, 2016 · 2 comments
Open

Feature Request: Library statistics in footer #61

oskameDEV opened this issue Dec 2, 2016 · 2 comments

Comments

@oskameDEV
Copy link

Title explains a lot.

I thought it might be neat if the footer showed your Plex's library stats.

1000 Movies | 345 Episodes | 1144 Songs
x Days x Hours of entertainment.

@justinglock40
Copy link

justinglock40 commented Dec 21, 2016

Also, Maybe add the resolution of the file. So users can see the quality of the media in the newsletter?

Anyway to make the background of the email a darker color such as black or gray?

@oskameDEV
Copy link
Author

oskameDEV commented Dec 21, 2016

I forgot to follow up on this. But for those with Plexpy there is an API you can use.
You'll have to edit the html in /scripts/plexEmail.py

Here's roughly what I'm using.

After the import section (top of the file) or near it.

## STATS JSON ##
def GetTime(seconds):
    minutes, seconds = divmod(seconds, 60)
    hours, minutes = divmod(minutes, 60)
    days, hours = divmod(hours, 24)
    return str(days)+'DAYS ' + str(hours)+'HOURS ' + str(minutes)+'MINUTES'

url = urllib.urlopen('http://192.168.0.222:8181/api/v2?apikey=XXX&cmd=get_libraries').read()
url = json.loads(url)

statsJSON = url.get('response')
statsJSON = statsJSON['data']

statsTotal = 'MOVIES ' + statsJSON[0]['count'] + ' | SHOWS ' + statsJSON[1]['count'] + ' | EPISODES ' + statsJSON[1]['child_count']

timeTVsecs = int(statsJSON[1]['child_count'])
timeTVsecs = timeTVsecs*2400
timeTV = GetTime(timeTVsecs)

timeMoviesSecs = int(statsJSON[0]['count'])
timeMoviesSecs = timeMoviesSecs*6900
timeMovies = GetTime(timeMoviesSecs)

and after <!-- /.container —> footer

        <div id="footer"><center>
        <h1 style="font-size:2em;color: #f39c12 !important;width: 100%; text-align: center;">Stats</h1>
        <h2 style="font-size:1em;color: #f39c12 !important;width: 100%; text-align: left; width:75%">&#9889;  """ + statsTotal + """</h2>
        <h2 style="font-size:1em;color: #f39c12 !important;width: 100%; text-align: left; width:75%">&#127909; """ + timeMovies + """</h2>
        <h2 style="font-size:1em;color: #f39c12 !important;width: 100%; text-align: left; width:75%">&#128250;  """ + timeTV + """</h2>
        <img src="http://res.cloudinary.com/fluxcapa/image/upload/c_scale,w_250/v1480731212/ASSETS/giphy.gif" width="125" height="125" style="border-radius:250px; /><div style="clear:both;></div>
        <h1 style="font-size:2em;color: #f39c12 !important;width: 100%; text-align: center;"><b>Have fun watching!</b></h1>
        </center></div>

Edit the IP 192.168.0.222 and XXX to the API key in Plexpy admin page settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants