It is currently Fri Dec 06, 2019 7:15 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: YouTube Player & Downloader
PostPosted: Fri Jul 28, 2017 1:36 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1595
-----------------------------------------------------------------------------------

Download YouTube Player & Downloader from My PureBasic Stuff

-----------------------------------------------------------------------------------

Tricks 'n' Tips
PureBasic Interface to OpenCV
PureBasic Interface to WinDivert
PureBasic Interface to WinRAR
PureBasic Interface to 7-Zip
PureBasic Interface to ImDisk
Windows Services & Other Stuff
Invading Space Aliens
Death Star vs Asteroids
GIF Toolkit
LSB File Embedding
Spider Web Drawing
Deform Image: MLS
Video Snipping Tool
Stitch Images: SIFT
Image Waves: LUT
YouTube Player & Downloader
MP4 Player & Downloader
Barcode Generator
Embed JS into PureBasic
Geolocation: Google Maps
Book & Viewer & Magnify
Video for Windows: VfW
Alternate Console
Network Share Management

-----------------------------------------------------------------------------------

FEATURES
- resizable main window
- full screen mode
- numerous command parameters
- search window with drag n' drop
- search window playlist

In order to keep the binary file a standalone executable, I have opted to save the Playlist items to an Alternate Data Stream.
- the Playlist can be demonstrated from the IDE, but the items will not survive a restart, unlike the compiled executable

Player Window:
- F1 Key: Toggle Shortcut Menu
- F2 Key: Open Search Window

- F10 Key: Redirect Video Request to YouTube Home Page
- F12 Key: Reload Default Video

- Esc Key: Exit Full Screen / Close Window

Search Window (search field has focus):
- Enter Key: Submit Search Filter
- Down Arrow + CTRL: Scroll to First Search Result
- Up Arrow + CTRL: Scroll to Last Search Result
- Left Arrow + CTRL: Scroll to Previous Search Result
- Right Arrow + CTRL: Scroll to Next Search Result
- Spacebar + CTRL: Submit Current Search Result

- Ins Key: Add Playlist Items (show playlist with first insert)
- Del Key: Delete PlayList Items (hide playlist after last delete)

Search Window (playlist has focus):
- Down Arrow: Scroll Down Playlist
- Up Arrow: Scroll Up Playlist
- Left Arrow + CTRL: Scroll to First Item
- Right Arrow + CTRL: Scroll to Last Item
- Spacebar + CTRL: Submit Selected Item

- Esc Key: Close Window

Command Parameters
- VID || VideoID : set a start video when the player is opened; YouTube video ID
- M || Maximized : open the window maximzed (DEFAULT: 0 || 1)
- X : open the window at x location
- Y : open the window at y location
- W || Width : set the starting window width
- H || Height : set the starting window height
- MW || MinWidth : set the minimum window width
- MH || MinHeight : set the minimum window height
- FS || FullScreen : open the window in full screen (DEFAULT: 0 || 1)
- FSX || FullScreenX : open the window in full screen at x location
- FSY || FullScreenY : open the window in full screen at y location
- FSW || FullScreenWidth : set the full screen width
- FSH || FullScreenHeight : set the full screen height
- AS || AutoStart : attempt to start the video without user interaction (DEFAULT: 1 || 0)
- LV || LoopVideo : restart the video or playlist after it completes (DEFAULT: 1 || 0)
- SR || SaveResult : save search results (JSON file) to a subfolder in the same directory as the executable (DEFAULT: 0 || 1)
- MR || MaxResult : set the maximum number of search results (per page) that can be returned per request (DEFAULT: 10 || 1 - 50)
- OB || OrderBy : search parameter (DEFAULT: relevance || date | rating | title | videoCount | viewCount)
- RC || RegionCode : search parameter (DEFAULT: null || ISO 3166-1 alpha-2 Code)
- RL || RelevanceLanguage : search parameter (DEFAULT: en || ISO 639-1 Code)
- SS || SafeSearch : search parameter (DEFAULT: none || moderate | strict)
- VC || VideoCaption : search parameter (DEFAULT: none || any | closedCaption)
- VD || VideoDefinition : search parameter (DEFAULT: any || high | standard)
- VI || VideoDimension : search parameter (DEFAULT: 2d || 3d | any)
- VU || VideoDuration : search parameter (DEFAULT: any || long | medium | short)
- VE || VideoEmbeddable : search parameter (DEFAULT: any || true)
- VT || VideoType : search parameter (DEFAULT: any || episode | movie)
- APIK || APIkey : get a personal API key from here (required for searches); not sure how long the current key will be valid

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Fri Oct 11, 2019 1:12 am, edited 69 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Fri Jul 28, 2017 2:02 pm 
Offline
Moderator
Moderator
User avatar

Joined: Thu Dec 31, 2009 11:05 pm
Posts: 1107
Location: Berlin (Germany)
Works fine, thank you. Image

Can you define all variables? (EnableExplicit)

_________________
ImageImageImageImage Image


Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Fri Jul 28, 2017 2:29 pm 
Offline
Addict
Addict

Joined: Sat Mar 02, 2013 9:17 am
Posts: 931
Very nice !

_________________
http://www.nachtoptik.de


Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Fri Jul 28, 2017 3:18 pm 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1706
Location: Uttoxeter, UK
@JHPJHP,
Excellent.
Thank you, very much for sharing. :D

_________________
DE AA EB


Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Fri Jul 28, 2017 5:17 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon May 10, 2010 4:02 pm
Posts: 153
There is no error handler:
Current item is not in the list


Last edited by kvitaliy on Thu Aug 03, 2017 10:43 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Fri Jul 28, 2017 7:14 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Sep 21, 2011 9:11 am
Posts: 606
Location: France
Thanks ^-^

_________________

➽ Windows 10 - PB 5.62 & PB 5.70 LTS

Sorry for my bad english and the Dunning–Kruger effect.


Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Sat Jul 29, 2017 12:29 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1595
Hi RSBasic, walbus, davido, kvitaliy, and falsam,

Thank you all for your comments...

RSBasic: If I started defining variables in this example, my OCD would force me to update everything I have ever posted. :mrgreen:

kvitaliy: Thank you for pointing out the error.

------------------------------------------------------

Updated:
- search window now returns multiple results
-- user-defined Structure field for Max Results, currently set to 10
-- hard-coded max of 50 results, overrides user-defined setting if greater then max
- search window settings are saved while the program is open
- some minor improvements when loading YouTube videos
- added additional error checking (thanks kvitaliy)

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Jul 31, 2017 4:46 am, edited 4 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Sat Jul 29, 2017 3:24 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon May 10, 2010 4:02 pm
Posts: 153
Thanks, good work!


Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Sun Jul 30, 2017 7:10 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1595
Hi kvitaliy,

You are most welcome.

I wanted to see how the example compiled, and noticed that there was still an external image...

Updated:
- compressed the external image, converted it to base64, than added it as an include file
- update also includes additional shortcut keys and a few small enhancements

NB*: Package now includes a compiled standalone executable.

--------------------------------------------------------------

Reposted the update...

Adding some Shortcut Keys without including a Constant affected typing into the search field.

Additional Shortcut Keys:
- Esc Key: exit Full Screen / close window
- Enter: submit search filter (field must have focus)
- Down Arrow + CTRL: scroll to first search result
- Left Arrow + CTRL: scroll to previous search result
- Right Arrow + CTRL: scroll to next search result
- Up Arrow + CTRL: scroll to last search result
- Spacebar + CTRL: submit current search result

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Aug 07, 2017 8:27 am, edited 5 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Sun Jul 30, 2017 9:31 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1595
Updated:
- updated Structures
- extended the search results
- improved the Search Filter
- optimized and cleaned up parts of the code

After scrolling to the last record, press the Next or Last button a second time, and a new request is made to the YouTube server for the next set of videos.
- if there are additional videos available, a plus [ + ] sign is displayed to the right of the count

After scrolling to the first record, press the Previous or First button a second time, and a new request is made to the YouTube server for the previously returned search results.
- if there are previously returned search results, a minus [ - ] sign is displayed to the left of the count

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Mon Jul 31, 2017 8:01 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13638
Location: France
Works perfectly :)


Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Mon Jul 31, 2017 7:12 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4542
Location: Lyon - France
Again a good works :wink:
Thanks to sharing 8)

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Wed Aug 02, 2017 1:42 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1595
Hi Fred,

Thank you for taking the time to give it try. I cannot say enough how great PureBasic is; limitless :!:

Hi Kwai chang caine,

As always your support is appreciated; it stands out from the crowd.

-------------------------------------------------

Updated:
- included a small Playlist feature
- added some additional Shortcut Keys
- optimized various parts of the code

In order to keep the binary file a standalone executable, I have opted to save the Playlist items to an Alternate Data Stream.
- the Playlist can be demonstrated from the IDE, but the items will not survive a restart, unlike the compiled executable

Player Window:
- F1 Key: Toggle Shortcut Menu
- F2 Key: Open Search Window

- F10 Key: Redirect Video Request to YouTube Home Page
- F12 Key: Reload Default Video

- Esc Key: Exit Full Screen / Close Window

Search Window (search field has focus):
- Enter Key: Submit Search Filter
- Down Arrow + CTRL: Scroll to First Search Result
- Up Arrow + CTRL: Scroll to Last Search Result
- Left Arrow + CTRL: Scroll to Previous Search Result
- Right Arrow + CTRL: Scroll to Next Search Result
- Spacebar + CTRL: Submit Current Search Result

- Ins Key: Add Playlist Items (show playlist with first insert)
- Del Key: Delete PlayList Items (hide playlist after last delete)

Search Window (playlist has focus):
- Down Arrow: Scroll Down Playlist
- Up Arrow: Scroll Up Playlist
- Left Arrow + CTRL: Scroll to First Item
- Right Arrow + CTRL: Scroll to Last Item
- Spacebar + CTRL: Submit Selected Item

- Esc Key: Close Window

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Sun Aug 13, 2017 9:31 am, edited 4 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Thu Aug 03, 2017 5:17 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1595
Updated:
- modified the Playlist
- added a Loop option (default True), resulting in additional player controls

If the Playlist is hidden, the Submit button will load a video from the Search list.

If the Playlist is visible, the Submit button will load one or more videos, starting from the selected item down.
- a single video can be loaded by double-clicking the item, or using the Shortcut keys

A video can be loaded from the Search list using the Shortcut keys, even when the Playlist is visible, but the Search field must have focus.

NB*: See the previous post for a list of Shortcut keys.

-------------------------------------------------

Updated:
- added Drag and Drop
- [ F1 ] Information

After searching for videos, put your mouse cursor over the returned image. Initially you will Drag and Drop your selection onto the YouTube logo, enabling the Playlist.
- Drag and Drop any new items directly into the Playlist

NB*: Because the WebGadget does not support Drag and Drop, I came up with a simple workaround.

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: YouTube Player
PostPosted: Fri Aug 04, 2017 12:46 am 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1595
Updated:
- added a Splash window
- added Command Parameters

1. Create a Shortcut from the executable.
2. From Properties / Shortcut / Target add the parameters.
3. Parameters use the following strict format: [parameter]=[value] [parameter]=[value] ...
-- Spaces are only allowed / required to seperate parameters.
-- Quotes are allowed, but not necessry.
-- Syntax is case insensitive.

Command Parameters
- VID || VideoID : set a start video when the player is opened; YouTube video ID
- M || Maximized : open the window maximzed (DEFAULT: 0 || 1)
- X : open the window at x location
- Y : open the window at y location
- W || Width : set the starting window width
- H || Height : set the starting window height
- MW || MinWidth : set the minimum window width
- MH || MinHeight : set the minimum window height
- FS || FullScreen : open the window in full screen (DEFAULT: 0 || 1)
- FSX || FullScreenX : open the window in full screen at x location
- FSY || FullScreenY : open the window in full screen at y location
- FSW || FullScreenWidth : set the full screen width
- FSH || FullScreenHeight : set the full screen height
- AS || AutoStart : attempt to start the video without user interaction (DEFAULT: 1 || 0)
- LV || LoopVideo : restart the video or playlist after it completes (DEFAULT: 1 || 0)
- SR || SaveResult : save search results (JSON file) to a subfolder in the same directory as the executable (DEFAULT: 0 || 1)
- MR || MaxResult : set the maximum number of search results (per page) that can be returned per request (DEFAULT: 10 || 1 - 50)
- OB || OrderBy : search parameter (DEFAULT: relevance || date | rating | title | videoCount | viewCount)
- RC || RegionCode : search parameter (DEFAULT: null || ISO 3166-1 alpha-2 Code)
- RL || RelevanceLanguage : search parameter (DEFAULT: en || ISO 639-1 Code)
- SS || SafeSearch : search parameter (DEFAULT: none || moderate | strict)
- VC || VideoCaption : search parameter (DEFAULT: none || any | closedCaption)
- VD || VideoDefinition : search parameter (DEFAULT: any || high | standard)
- VI || VideoDimension : search parameter (DEFAULT: 2d || 3d | any)
- VU || VideoDuration : search parameter (DEFAULT: any || long | medium | short)
- VE || VideoEmbeddable : search parameter (DEFAULT: any || true)
- VT || VideoType : search parameter (DEFAULT: any || episode | movie)
- APIK || APIkey : get a personal API key from here (required for searches); not sure how long the current key will be valid

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Last edited by JHPJHP on Mon Aug 07, 2017 6:57 pm, edited 3 times in total.

Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye