Skip to content

Commit ee73d6e

Browse files
authored
Minor improvement of example scripts (#847)
1 parent a7d3e79 commit ee73d6e

10 files changed

Lines changed: 35 additions & 11 deletions

examples/bbciplayer_example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
}
8686
quick_play.quick_play(cast, app_name, app_data)
8787

88-
sleep(10)
88+
# If debugging, sleep after running so we can see any error messages.
89+
if args.show_debug:
90+
sleep(10)
8991

9092
browser.stop_discovery()

examples/bbcsounds_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Example on how to use the BBC iPlayer Controller
2+
Example on how to use the BBC Sounds Controller
33
"""
44

55
# pylint: disable=invalid-name
@@ -96,6 +96,8 @@
9696
}
9797
quick_play.quick_play(cast, app_name, app_data)
9898

99-
sleep(10)
99+
# If debugging, sleep after running so we can see any error messages.
100+
if args.show_debug:
101+
sleep(10)
100102

101103
browser.stop_discovery()

examples/bubbleupnp_example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
}
7272
quick_play.quick_play(cast, app_name, app_data)
7373

74-
sleep(10)
74+
# If debugging, sleep after running so we can see any error messages.
75+
if args.show_debug:
76+
sleep(10)
7577

7678
browser.stop_discovery()

examples/default_media_receiver_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Example on how to use the Home Assistant Media app to play an URL.
2+
Example on how to use the Default Media Controller app to play an URL.
33
44
"""
55

@@ -65,6 +65,8 @@
6565
}
6666
quick_play.quick_play(cast, app_name, app_data)
6767

68-
sleep(10)
68+
# If debugging, sleep after running so we can see any error messages.
69+
if args.show_debug:
70+
sleep(10)
6971

7072
browser.stop_discovery()

examples/homeassistant_media_example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
}
6767
quick_play.quick_play(cast, app_name, app_data)
6868

69-
sleep(10)
69+
# If debugging, sleep after running so we can see any error messages.
70+
if args.show_debug:
71+
sleep(10)
7072

7173
browser.stop_discovery()

examples/nrkradio_example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
}
6868
quick_play.quick_play(cast, app_name, app_data)
6969

70-
sleep(10)
70+
# If debugging, sleep after running so we can see any error messages.
71+
if args.show_debug:
72+
sleep(10)
7173

7274
browser.stop_discovery()

examples/nrktv_example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
}
6868
quick_play.quick_play(cast, app_name, app_data)
6969

70-
sleep(10)
70+
# If debugging, sleep after running so we can see any error messages.
71+
if args.show_debug:
72+
sleep(10)
7173

7274
browser.stop_discovery()

examples/shaka_drm_example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@
113113

114114
quick_play.quick_play(cast, app_name, app_data)
115115

116-
sleep(10)
116+
# If debugging, sleep after running so we can see any error messages.
117+
if args.show_debug:
118+
sleep(10)
117119

118120
browser.stop_discovery()

examples/yleareena_example.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ def get_kaltura_id(program_id: str) -> str:
9292
"text_lang": args.text_language,
9393
}
9494
quick_play.quick_play(cast, app_name, app_data)
95-
sleep(10)
95+
96+
# If debugging, sleep after running so we can see any error messages.
97+
if args.show_debug:
98+
sleep(10)
9699

97100
# Shut down discovery
98101
browser.stop_discovery()

examples/youtube_example.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import argparse
99
import sys
10+
from time import sleep
1011

1112
import pychromecast
1213
from pychromecast.controllers.youtube import YouTubeController
@@ -62,5 +63,9 @@
6263
cast.register_handler(yt)
6364
yt.play_video(VIDEO_ID)
6465

66+
# If debugging, sleep after running so we can see any error messages.
67+
if args.show_debug:
68+
sleep(10)
69+
6570
# Shut down discovery
6671
browser.stop_discovery()

0 commit comments

Comments
 (0)