Beispiel #1
0
 def handle(self, show, clip_id, **options):
         client = JtvClient(JTVKey, JTVSecret)
         clip_show = Show.objects.get(name=show)
         token = OAuthToken(clip_show.jtv_token, clip_show.jtv_secret)
         response = client.post('/clip/destroy/' + clip_id + '.xml', {}, token ).read()
         
         # Parse response to confirm success
         p = SimpleParserSingle()
         p.feed(response, 'message')
         print p.data
Beispiel #2
0
    def handle_noargs(self, **options):
            client = JtvClient(JTVKey, JTVSecret)
            day = Day.objects.get(name=strftime("%A", localtime()))
            try:
                timeslots = TimeSlot.objects.filter(day=day)
            except(TimeSlot.DoesNotExist):
                print "No timeslots found for this day"
                return
            clip_errors = []
            for timeslot in timeslots:
                # Get a current datetime
                day = date.today()
                # Change the time portion for the episode
                start = datetime(day.year, day.month, day.day, timeslot.military_time)
                end = datetime(day.year, day.month, day.day, timeslot.military_time + 1)

                # Convert to epoch time
                start_time = time.mktime(start.timetuple())
                end_time = time.mktime(end.timetuple())

                show = timeslot.last_week_winner

                #Change this to use the shows credentials
                token = OAuthToken(show.jtv_token, show.jtv_secret)
                clip = client.post('/clip/create.xml', {
                    'start_time': start_time,
                    'end_time': end_time,
                    'title': show.name,
                    'description': str(date.today()),
                    'tags': "woot",
                }, token).read()

                print clip 
                # Parse response to confirm success
                p = SimpleParserSingle()
                p.feed(clip, 'id')
                if not p.data:
                    clip_errors.append("Timeslot:" + str(timeslot) + ";Show:" + show.name)
                
            # Sends email if any errors
            if clip_errors:
                mail_admins("Error creating clips", str(clip_errors))