Python Forum
Help with calling the function as the code keep firing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with calling the function as the code keep firing
#8
It look like to me you don't understand what I am trying to do. I am fetching the url from the database to play the video. If the video link is dead, I want to fetch the new video link in the database and play the video. This is what I am trying to do. I hope this is clear to you?

On your code that you wrote, it will fetch the url from the column stream1_url to play the video but the video link I am trying to play is dead so the code that you wrote did not call the play function again to fetch the new link from the column stream2_url when the video link is dead. I think you need to read my post again to try to understand what I am trying to achieve.


(May-03-2018, 08:27 PM)ThiefOfTime Wrote: Depending on what you want to do if you do not find a functioning link. currently you keep on trying the first url.
possibility one: just one test over all urls
def play(self, item = None, windowed = False):
    print "you are working on play.........................."
    max_number_urls = 3
    bool = True
    url = ''
    if not self.player.isPlayingVideo():
       conn = database.connect(self.profilePath + 'source.db')
       cur = conn.cursor()
       self.count += 1
       print "self.count...............................for stream_url column"
       print self.count
       try:
          while self.count <= max_number_urls:
              cur.execute('SELECT stream%i_url FROM streams WHERE channels=?' % self.count, [self.EPG_Channel])
              data = cur.fetchone()
              if data is not None:
                 # you found an url in the database
                 url = data[0]
                 if self.check_url_functioning() == True:
                       break
              self.count += 1
           if self.count == max_number_urls + 1:
              raise RuntimeError("no URL works")               
       except:
           print "All URLs down"
       conn.close()
       self.player.play(url, windowed = bool)
       self.channel_pressed = False
what you could do alternatively is keep on searching through the known urls if they will come back some day. or you may do that just (lets say) 10 times before checking the next one. then use a counter to count the repetitions. Or a timer if you want to do ist every 5 seconds :)
Reply


Messages In This Thread
RE: Help with calling the function as the code keep firing - by chris0147 - May-03-2018, 09:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  calling external function with arguments Wimpy_Wellington 7 1,549 Jul-05-2023, 06:33 PM
Last Post: deanhystad
  Calling a function (which accesses a library) from another file mouse9095 4 864 Jun-07-2023, 08:55 PM
Last Post: deanhystad
Sad Iterate randint() multiple times when calling a function Jake123 2 2,127 Feb-15-2022, 10:56 PM
Last Post: deanhystad
  Calling a class from a function jc4d 5 1,908 Dec-17-2021, 09:04 PM
Last Post: ndc85430
  [Solved] TypeError when calling function Laplace12 2 2,960 Jun-16-2021, 02:46 PM
Last Post: Laplace12
  Putting code into a function breaks its functionality, though the code is identical! PCesarano 1 2,041 Apr-05-2021, 05:40 PM
Last Post: deanhystad
  calling a function and argument in an input phillup7 3 2,679 Oct-25-2020, 02:12 PM
Last Post: jefsummers
  Function Recognises Variable Without Arguments Or Global Variable Calling. OJGeorge4 1 2,302 Apr-06-2020, 09:14 AM
Last Post: bowlofred
  Calling DLL function OptoBruh 0 1,622 Nov-15-2019, 11:51 PM
Last Post: OptoBruh
  Duplicate output when calling a custom function from the same file? road2knowledge 2 2,446 May-10-2019, 07:58 AM
Last Post: road2knowledge

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020