File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,6 +41,22 @@ public function latestVideo(Request $request)
4141 $ skip = 0 ;
4242 }
4343
44+ /**
45+ * Channel IDs and old "user" URLs do not have spaces in them.
46+ *
47+ * Some users have specified their display names (example: "My Channel Name")
48+ * as their channel ID, which will just return an error from the YouTube API.
49+ *
50+ * To prevent unnecessary API requests, we're returning an error early as
51+ * this would be an invalid ID/user value anyways.
52+ */
53+ if (strpos ($ id , ' ' ) !== false ) {
54+ return Helper::text (__ ('youtube.invalid_channel_value ' , [
55+ 'type ' => $ type ,
56+ 'id ' => $ id ,
57+ ]));
58+ }
59+
4460 try {
4561 switch ($ type ) {
4662 case 'user ' :
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * English translation strings for YouTube-related endpoints.
5+ */
6+
7+ return [
8+ /**
9+ * For /youtube/latest_video when someone specifies an
10+ * invalid channel ID (/channel/ URLs) or user (/user/ URLs).
11+ */
12+ 'invalid_channel_value ' => 'Invalid YouTube channel (:type) specified: :id ' ,
13+ ];
You can’t perform that action at this time.
0 commit comments