Functions/GenXdev.Console.Vlc/Open-VlcMediaPlayerLyrics.ps1
############################################################################### function Open-VlcMediaPlayerLyrics { [CmdletBinding()] [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '')] [Alias('vlclyrics')] param ( [parameter( Mandatory = $false, Position = 0, ValueFromRemainingArguments, ValueFromPipeline, ValueFromPipelineByPropertyName, HelpMessage = 'Search terms to find a track' )] [Alias('q', 'Name', 'Text', 'Query')] [string[]] $Queries, ############################################################################### [ValidateSet( 'Bing', 'Github', 'Google', 'IMDB', 'InstantStreetView', 'StackOverflow', 'Wikipedia', 'WikipediaNL', 'WolframAlpha', 'Youtube' )] [parameter( Mandatory = $false, Position = 1, HelpMessage = 'The enpoint to invoke the query on' )] [string] $EndPoint = 'Google', ############################################################################### [ValidateSet( 'Afrikaans', 'Akan', 'Albanian', 'Amharic', 'Arabic', 'Armenian', 'Azerbaijani', 'Basque', 'Belarusian', 'Bemba', 'Bengali', 'Bihari', 'Bork, bork, bork!', 'Bosnian', 'Breton', 'Bulgarian', 'Cambodian', 'Catalan', 'Cherokee', 'Chichewa', 'Chinese (Simplified)', 'Chinese (Traditional)', 'Corsican', 'Croatian', 'Czech', 'Danish', 'Dutch', 'Elmer Fudd', 'English', 'Esperanto', 'Estonian', 'Ewe', 'Faroese', 'Filipino', 'Finnish', 'French', 'Frisian', 'Ga', 'Galician', 'Georgian', 'German', 'Greek', 'Guarani', 'Gujarati', 'Hacker', 'Haitian Creole', 'Hausa', 'Hawaiian', 'Hebrew', 'Hindi', 'Hungarian', 'Icelandic', 'Igbo', 'Indonesian', 'Interlingua', 'Irish', 'Italian', 'Japanese', 'Javanese', 'Kannada', 'Kazakh', 'Kinyarwanda', 'Kirundi', 'Klingon', 'Kongo', 'Korean', 'Krio (Sierra Leone)', 'Kurdish', 'Kurdish (Soranî)', 'Kyrgyz', 'Laothian', 'Latin', 'Latvian', 'Lingala', 'Lithuanian', 'Lozi', 'Luganda', 'Luo', 'Macedonian', 'Malagasy', 'Malay', 'Malayalam', 'Maltese', 'Maori', 'Marathi', 'Mauritian Creole', 'Moldavian', 'Mongolian', 'Montenegrin', 'Nepali', 'Nigerian Pidgin', 'Northern Sotho', 'Norwegian', 'Norwegian (Nynorsk)', 'Occitan', 'Oriya', 'Oromo', 'Pashto', 'Persian', 'Pirate', 'Polish', 'Portuguese (Brazil)', 'Portuguese (Portugal)', 'Punjabi', 'Quechua', 'Romanian', 'Romansh', 'Runyakitara', 'Russian', 'Scots Gaelic', 'Serbian', 'Serbo-Croatian', 'Sesotho', 'Setswana', 'Seychellois Creole', 'Shona', 'Sindhi', 'Sinhalese', 'Slovak', 'Slovenian', 'Somali', 'Spanish', 'Spanish (Latin American)', 'Sundanese', 'Swahili', 'Swedish', 'Tajik', 'Tamil', 'Tatar', 'Telugu', 'Thai', 'Tigrinya', 'Tonga', 'Tshiluba', 'Tumbuka', 'Turkish', 'Turkmen', 'Twi', 'Uighur', 'Ukrainian', 'Urdu', 'Uzbek', 'Vietnamese', 'Welsh', 'Wolof', 'Xhosa', 'Yiddish', 'Yoruba', 'Zulu')] [parameter( Mandatory = $false, Position = 2, HelpMessage = 'The language of the returned search results' )] [string] $Language, ######################################################################## [Parameter( Mandatory = $false, HelpMessage = 'Opens in incognito/private browsing mode' )] [Alias('incognito', 'inprivate')] [switch] $Private, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Force enable debugging port, stopping existing browsers if needed' )] [switch] $Force, ############################################################################### [Alias('e')] [Parameter( Mandatory = $false, HelpMessage = 'Opens in Microsoft Edge' )] [switch] $Edge, ############################################################################### [Alias('ch')] [Parameter( Mandatory = $false, HelpMessage = 'Opens in Google Chrome' )] [switch] $Chrome, ############################################################################### [Alias('c')] [Parameter( Mandatory = $false, HelpMessage = 'Opens in Microsoft Edge or Google Chrome, depending on what the default browser is' )] [switch] $Chromium, ############################################################################### [Alias('ff')] [Parameter( Mandatory = $false, HelpMessage = 'Opens in Firefox' )] [switch] $Firefox, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Opens in all registered modern browsers' )] [switch] $All, ############################################################################### [Alias('m', 'mon')] [Parameter( Mandatory = $false, HelpMessage = 'The monitor to use, 0 = default, -1 is discard, -2 = Configured secondary monitor, defaults to -1, no positioning' )] [int] $Monitor = -1, ############################################################################### [Alias('sw')] [Parameter( Mandatory = $false, HelpMessage = 'Opens in fullscreen mode' )] [switch]$ShowWindow, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'The initial width of the webbrowser window' )] [int] $Width = -1, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'The initial height of the webbrowser window' )] [int] $Height = -1, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'The initial X position of the webbrowser window' )] [int] $X = -999999, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'The initial Y position of the webbrowser window' )] [int] $Y = -999999, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Place browser window on the left side of the screen' )] [switch] $Left, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Place browser window on the right side of the screen' )] [switch] $Right, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Place browser window on the top side of the screen' )] [switch] $Top, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Place browser window on the bottom side of the screen' )] [switch] $Bottom, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Place browser window in the center of the screen' )] [switch] $Centered, ############################################################################### [Alias('a', 'app', 'appmode')] [Parameter( Mandatory = $false, HelpMessage = 'Hide the browser controls' )] [switch] $ApplicationMode, ############################################################################### [Alias('de', 'ne', 'NoExtensions')] [Parameter( Mandatory = $false, HelpMessage = 'Prevent loading of browser extensions' )] [switch] $NoBrowserExtensions, ####################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Disable the popup blocker' )] [Alias('allowpopups')] [switch] $DisablePopupBlocker, ############################################################################### [Alias('lang', 'locale')] [Parameter( Mandatory = $false, HelpMessage = 'Set the browser accept-lang http header' )] [string] $AcceptLang = $null, ########################################################################### [Parameter( Mandatory = $false, HelpMessage = ('Keystrokes to send to the Browser window, ' + 'see documentation for cmdlet GenXdev.Windows\Send-Key') )] [string[]] $KeysToSend, ####################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Escape control characters when sending keys' )] [Alias('Escape')] [switch] $SendKeyEscape, ####################################################################### [Parameter( Mandatory = $false, HelpMessage = ('Prevent returning keyboard focus to PowerShell ' + 'after sending keys') )] [Alias('HoldKeyboardFocus')] [switch] $SendKeyHoldKeyboardFocus, ####################################################################### [Parameter( Mandatory = $false, HelpMessage = ('Send Shift+Enter instead of regular Enter for ' + 'line breaks') )] [Alias('UseShiftEnter')] [switch] $SendKeyUseShiftEnter, ####################################################################### [Parameter( Mandatory = $false, HelpMessage = ('Delay between sending different key sequences ' + 'in milliseconds') )] [Alias('DelayMilliSeconds')] [int] $SendKeyDelayMilliSeconds, ######################################################################## [Parameter( Mandatory = $false, HelpMessage = 'Focus the browser window after opening' )] [Alias('fw','focus')] [switch] $FocusWindow, ######################################################################## [Parameter( Mandatory = $false, HelpMessage = 'Set the browser window to foreground after opening' )] [Alias('fg')] [switch] $SetForeground, ######################################################################## [Parameter( Mandatory = $false, HelpMessage = 'Maximize the window after positioning' )] [switch] $Maximize, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Restore PowerShell window focus' )] [Alias('rf', 'bg')] [switch]$RestoreFocus, ############################################################################### [Alias('nw', 'new')] [Parameter( Mandatory = $false, HelpMessage = "Don't re-use existing browser window, instead, create a new one" )] [switch] $NewWindow, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Returns a [System.Diagnostics.Process] object of the browserprocess' )] [Alias('pt')] [switch]$PassThru, ######################################################################## [parameter( Mandatory = $false, HelpMessage = "Don't open webbrowser, just return the url" )] [switch] $ReturnURL, ######################################################################## [parameter( Mandatory = $false, HelpMessage = 'After opening webbrowser, return the url' )] [switch] $ReturnOnlyURL, ######################################################################## [Parameter( Mandatory = $false, HelpMessage = 'Removes window borders from the browser window' )] [Alias('nb')] [switch] $NoBorders, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Use a session that is not persisted after closing the browser' )] [switch] $SessionOnly, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Clear browser session data before opening the browser' )] [switch] $ClearSession, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Skip using any existing browser session' )] [Alias('FromPreferences')] [switch] $SkipSession, ############################################################################### [Parameter( Mandatory = $false, HelpMessage = 'Open browser windows side by side' )] [Alias('sbs')] [switch] $SideBySide ######################################################################## ) begin { # initialize any variables needed across process block calls $queryList = @() } process { # handle each pipeline input object if ($Queries) { $queryList += $Queries } } end { $w = GenXdev.Windows\Get-Window -ProcessName vlc if ($null -ne $w) { if (@(Microsoft.PowerShell.Core\Get-Module GenXdev.Queries -ErrorAction SilentlyContinue).Count -eq 0) { $null = PowerShellGet\Install-Module GenXdev.Queries -SkipPublisherCheck $null = Microsoft.PowerShell.Core\Import-Module GenXdev.Queries } $invocationArguments = GenXdev.Helpers\Copy-IdenticalParamValues ` -FunctionName 'GenXdev.Queries\Open-GoogleQuery' ` -BoundParameters $PSBoundParameters # if queries were collected from pipeline, use them, otherwise use window title if ($queryList.Count -gt 0) { $invocationArguments.Queries = $queryList } else { $invocationArguments.Queries = @('lyrics ' + $w.Title) } $null = GenXdev.Queries\Open-GoogleQuery @invocationArguments } } } |