Skip to content

Commit

Permalink
Run futurize --stage2
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyWong16 committed Jul 4, 2020
1 parent 30dbccd commit dc6507f
Show file tree
Hide file tree
Showing 32 changed files with 82 additions and 31 deletions.
1 change: 1 addition & 0 deletions fun/playlist_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"""

from builtins import str
import sys
import os
import random
Expand Down
9 changes: 6 additions & 3 deletions killstream/kill_else_if_buffering.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"""
from __future__ import print_function
from __future__ import division

from builtins import str
from past.utils import old_div
import requests
from operator import itemgetter
import unicodedata
Expand Down Expand Up @@ -44,7 +47,7 @@ def kill_session(sess_key, message):
# Check for users stream
username = session.usernames[0]
if session.sessionKey == sess_key:
title = unicode(session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
title = str(session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
title = unicodedata.normalize('NFKD', title).encode('ascii', 'ignore').translate(None, "'")
session.stop(reason=message)
print('Terminated {user}\'s stream of {title} to prioritize admin stream.'.format(user=username,
Expand All @@ -68,8 +71,8 @@ def main():
if trans_dec == 'transcode' and username not in ADMIN_USER:
sess_key = session.sessionKey
percent_comp = int((float(session.viewOffset) / float(session.duration)) * 100)
time_to_comp = int(int(session.duration) - int(session.viewOffset)) / 1000 / 60
title = unicode(session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
time_to_comp = old_div(old_div(int(int(session.duration) - int(session.viewOffset)), 1000), 60)
title = str(session.grandparentTitle + ' - ' if session.type == 'episode' else '') + session.title
title = unicodedata.normalize('NFKD', title).encode('ascii', 'ignore').translate(None, "'")
add_to_dictlist(user_dict, username, [sess_key, percent_comp, title, username, time_to_comp])

Expand Down
8 changes: 5 additions & 3 deletions killstream/kill_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
from __future__ import print_function


from builtins import object
from builtins import str
import os
import sys
import json
Expand Down Expand Up @@ -236,7 +238,7 @@ def basic_notify(notifier_id, session_id, username=None, message=None, stream=No
notification.send(SUBJECT_TEXT, body)


class Tautulli:
class Tautulli(object):
def __init__(self, url, apikey, verify_ssl=False, debug=None):
self.url = url
self.apikey = apikey
Expand Down Expand Up @@ -320,7 +322,7 @@ def terminate_session(self, session_key=None, session_id=None, message=''):
return self._call_api('terminate_session', payload)


class Stream:
class Stream(object):
def __init__(self, session_id=None, user_id=None, username=None, tautulli=None, session=None):
self.state = None
self.ip_address = None
Expand Down Expand Up @@ -406,7 +408,7 @@ def terminate_long_pause(self, message, limit, interval):
return False


class Notification:
class Notification(object):
def __init__(self, notifier_id, subject, body, tautulli, stream):
self.notifier_id = notifier_id
self.subject = subject
Expand Down
1 change: 1 addition & 0 deletions killstream/limiterr.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"""
from __future__ import print_function

from builtins import range
import requests
import argparse
from datetime import datetime, timedelta
Expand Down
10 changes: 7 additions & 3 deletions maps/ips_to_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"""
from __future__ import print_function

from builtins import zip
from builtins import str
from builtins import range
from builtins import object
import requests
import sys
import json
Expand Down Expand Up @@ -213,7 +217,7 @@ def get_geo_dict(length, users):

def get_geojson_dict(user_locations):
locs = []
for username, locations in user_locations.iteritems():
for username, locations in user_locations.items():
for location in locations:
try:
locs.append({
Expand Down Expand Up @@ -349,9 +353,9 @@ def draw_map(map_type, geo_dict, filename, headless, leg_choice):
0))
labels = labels[idx:] + labels[:idx]
handles = handles[idx:] + handles[:idx]
by_label = OrderedDict(zip(labels, handles))
by_label = OrderedDict(list(zip(labels, handles)))

leg = plt.legend(by_label.values(), by_label.keys(), fancybox=True, fontsize='x-small',
leg = plt.legend(list(by_label.values()), list(by_label.keys()), fancybox=True, fontsize='x-small',
numpoints=1, title="Legend", labelspacing=1., borderpad=1.5, handletextpad=2.)
if leg:
lleng = len(leg.legendHandles)
Expand Down
2 changes: 2 additions & 0 deletions notify/find_unwatched_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"""
from __future__ import print_function

from builtins import object
from builtins import str
import requests
import sys
import time
Expand Down
4 changes: 3 additions & 1 deletion notify/notify_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
Tautulli Settings > Notification Agents > Scripts (Gear) > Script Timeout: 0 to disable or set to > 180
"""
from __future__ import print_function
from __future__ import division

from past.utils import old_div
import requests
import sys
import argparse
Expand Down Expand Up @@ -67,7 +69,7 @@ def send_notification(subject_text, body_text):
"""Format notification text."""
try:
subject = subject_text.format(p=p, total=cc_total)
body = body_text.format(p=p, total=cc_total, time=TIMEOUT / 60)
body = body_text.format(p=p, total=cc_total, time=old_div(TIMEOUT, 60))

except LookupError as e:
sys.stderr.write("Unable to substitute '{0}' in the notification subject or body".format(e))
Expand Down
3 changes: 2 additions & 1 deletion notify/notify_fav_tv_all_movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""
from __future__ import print_function

from builtins import object
import requests
from email.mime.text import MIMEText
import email.utils
Expand Down Expand Up @@ -244,7 +245,7 @@ def send_email(to, email_subject, body_html):

if p.media_type == 'movie':
email_subject = MOVIE_SUBJECT.format(p=p)
to = filter(None, [x['email'] for x in get_users() if x['user_id'] not in IGNORE_LST])
to = [_f for _f in [x['email'] for x in get_users() if x['user_id'] not in IGNORE_LST] if _f]
body_html = MOVIE_BODY.format(p=p)
send_email(to, email_subject, body_html)

Expand Down
1 change: 1 addition & 0 deletions notify/notify_newip.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""
from builtins import object
import argparse
import requests
import sys
Expand Down
1 change: 1 addition & 0 deletions notify/notify_user_favorites.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""
from __future__ import print_function

from builtins import object
import requests
from email.mime.text import MIMEText
import email.utils
Expand Down
1 change: 1 addition & 0 deletions notify/notify_user_newip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Place in Playback Start
"""
from __future__ import print_function
from builtins import object
import argparse
import requests
import sys
Expand Down
2 changes: 2 additions & 0 deletions reporting/added_to_plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"""
from __future__ import print_function

from builtins import str
from builtins import object
import requests
import sys
import time
Expand Down
1 change: 1 addition & 0 deletions reporting/check_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# {user} {title}
# Add to Playback Resume

from builtins import object
import requests
import sys

Expand Down
1 change: 1 addition & 0 deletions reporting/check_plex_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"""
from __future__ import print_function

from builtins import object
import requests
import sys

Expand Down
1 change: 1 addition & 0 deletions reporting/library_play_days.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"""
from __future__ import print_function

from builtins import str
import requests
import sys
import argparse
Expand Down
1 change: 1 addition & 0 deletions reporting/plex_netflix_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"""
from __future__ import print_function

from builtins import str
import requests
import argparse
from xmljson import badgerfish as bf
Expand Down
1 change: 1 addition & 0 deletions reporting/userplays_weekly_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Notify via Tautulli Notification
"""

from builtins import object
import requests
import sys
import time
Expand Down
7 changes: 4 additions & 3 deletions reporting/watched_percentages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

from __future__ import print_function
from builtins import object
import time
import argparse
from plexapi.myplex import MyPlexAccount
Expand Down Expand Up @@ -40,7 +41,7 @@
timestr = time.strftime("%Y%m%d-%H%M%S")


class Connection:
class Connection(object):
def __init__(self, url=None, apikey=None, verify_ssl=False):
self.url = url
self.apikey = apikey
Expand Down Expand Up @@ -75,7 +76,7 @@ def __init__(self, data=None):
pass


class Tautulli:
class Tautulli(object):
def __init__(self, connection):
self.connection = connection

Expand Down Expand Up @@ -128,7 +129,7 @@ def get_libraries(self):
return self._call_api('get_libraries', payload)


class Plex:
class Plex(object):
def __init__(self, token, url=None):
if token and not url:
self.account = MyPlexAccount(token)
Expand Down
6 changes: 4 additions & 2 deletions reporting/weekly_stats_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"""
from __future__ import print_function
from builtins import range
from builtins import object
from plexapi.server import CONFIG
from datetime import datetime, timedelta, date
from requests import Session
Expand Down Expand Up @@ -220,7 +222,7 @@ def get_library_stats(libraries, tautulli, rich, notify=None):
return sections_stats_lst


class Tautulli:
class Tautulli(object):
def __init__(self, url, apikey, verify_ssl=False, debug=None):
self.url = url
self.apikey = apikey
Expand Down Expand Up @@ -317,7 +319,7 @@ def _call_api(self, cmd, payload, method='GET'):
return


class Notification:
class Notification(object):
def __init__(self, notifier_id, subject, body, tautulli, stats=None):
self.notifier_id = notifier_id
self.subject = subject
Expand Down
1 change: 1 addition & 0 deletions utility/delete_watched_TV.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""
from __future__ import print_function

from builtins import object
import requests
import sys
import os
Expand Down
5 changes: 4 additions & 1 deletion utility/find_unwatched.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"""
from __future__ import print_function

from builtins import input
from builtins import str
from builtins import object
import requests
import sys
import time
Expand Down Expand Up @@ -123,7 +126,7 @@ def get_libraries_table():


def delete_files(tmp_lst):
del_file = raw_input('Delete all unwatched files? (yes/no)').lower()
del_file = input('Delete all unwatched files? (yes/no)').lower()
if del_file.startswith('y'):
for x in tmp_lst:
print("Removing {}".format(x))
Expand Down
4 changes: 3 additions & 1 deletion utility/get_serial_transcoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
Requires: requests, plexapi, python3.6+
"""
from __future__ import print_function
from __future__ import division
from past.utils import old_div
from requests import Session
from plexapi.server import CONFIG
from datetime import date, timedelta
Expand Down Expand Up @@ -57,7 +59,7 @@
PARAMS = {'cmd': 'get_user', 'user_id': 0}
for user, counts in USERS.items():
TOTAL_PLAYS = counts['transcode'] + counts['direct play'] + counts['copy']
TRANSCODE_PERCENT = round(counts['transcode'] * 100 / TOTAL_PLAYS, 2)
TRANSCODE_PERCENT = round(old_div(counts['transcode'] * 100, TOTAL_PLAYS), 2)
if TRANSCODE_PERCENT >= THRESHOLD_PERCENT:
PARAMS['user_id'] = user
NAUGHTY = SESSION.get(FORMATTED_URL, params=PARAMS).json()['response']['data']
Expand Down
3 changes: 2 additions & 1 deletion utility/grab_gdrive_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
from __future__ import print_function

from builtins import input
import os
import httplib2

Expand Down Expand Up @@ -35,7 +36,7 @@
flow = OAuth2WebServerFlow(CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, REDIRECT_URI)
authorize_url = flow.step1_get_authorize_url()
print('Go to the following link in your browser: ' + authorize_url)
code = raw_input('Enter verification code: ').strip()
code = input('Enter verification code: ').strip()
credentials = flow.step2_exchange(code)
storage.put(credentials)

Expand Down
1 change: 1 addition & 0 deletions utility/mark_multiepisode_watched.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# --rating_key {rating_key} --filename {filename}

from __future__ import print_function
from builtins import str
import argparse
import os
from plexapi.server import PlexServer
Expand Down
5 changes: 3 additions & 2 deletions utility/media_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"""
from __future__ import print_function
from builtins import object
import argparse
import datetime
import time
Expand Down Expand Up @@ -71,7 +72,7 @@
'policyUnwatched': 0,
'videoQuality': None}

class Connection:
class Connection(object):
def __init__(self, url=None, apikey=None, verify_ssl=False):
self.url = url
self.apikey = apikey
Expand Down Expand Up @@ -160,7 +161,7 @@ def __init__(self, name='', email='', userid='',):
self.direct = {}


class Tautulli:
class Tautulli(object):
def __init__(self, connection):
self.connection = connection

Expand Down
1 change: 1 addition & 0 deletions utility/off_deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"""
from __future__ import print_function

from builtins import range
import requests
import argparse
import datetime
Expand Down
Loading

0 comments on commit dc6507f

Please sign in to comment.