Foxhound Posted September 15, 2010 Share Posted September 15, 2010 (edited) Simple script. Self-explanatory. In goes long link ---> Out comes TinyURL linkDownload:TinyURLfier.au3Latest update in last post! Edited February 26, 2011 by Foxhound [quote]Quick YouTube To MP3 | Lyrics Finder | Internet Radio Player | GetWeather | TinyURLifier[/quote] Link to comment Share on other sites More sharing options...
MrCreatoR Posted September 15, 2010 Share Posted September 15, 2010 I prefer to use bit.ly service, the generated links are shorten $sLong_Url = InputBox('Get Shorten Link', 'Enter long url to get shorten version:', 'http://www.autoitscript.com/autoit3/downloads.shtml') ;$CmdLine[2] If @error Then Exit $sUser_Name = 'autoit3user' $sAPI_Key = 'R_f4f7554a3e8648d85980a489bbc7fce8' $sShort_Url = InetRead('http://api.bit.ly/v3/shorten?login=' & $sUser_Name & '&apiKey=' & $sAPI_Key & '&longUrl=' & _EncodeURI($sLong_Url) & '&format=txt') $sShort_Url = StringStripWS(BinaryToString($sShort_Url), 3) InputBox('Get Shorten Link', 'Shorten version, copy to clipboard?', $sShort_Url) If Not @error Then ClipPut($sShort_Url) Func _EncodeURI($sURLString) Local $aURLStrSplit = StringSplit($sURLString, "") Local $sRetString = "" For $i = 1 To UBound($aURLStrSplit) - 1 If Not StringRegExp($aURLStrSplit[$i], '(?i)[a-z]|\.|-|_') Then $aURLStrSplit[$i] = "%" & Hex(Asc($aURLStrSplit[$i]), 2) $sRetString &= $aURLStrSplit[$i] Next Return $sRetString EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Foxhound Posted September 15, 2010 Author Share Posted September 15, 2010 Yeah I wanted to use bitly but I didn't want to sign up to get their api key and what not. Too much hassle. [quote]Quick YouTube To MP3 | Lyrics Finder | Internet Radio Player | GetWeather | TinyURLifier[/quote] Link to comment Share on other sites More sharing options...
MrCreatoR Posted September 15, 2010 Share Posted September 15, 2010 Too much hassleNot really, it took me less then a minute to register new account and get the api Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Foxhound Posted February 26, 2011 Author Share Posted February 26, 2011 (edited) New version available!Download TinyURLfier 1.5 via SourceForge SVNor Download here: TinyURLfier 1.5.au3Changes:__________________ - Total overhaul of the script - New changes to the GUI - Simpler regex pattern - Removed _InetGetSource() and implemented InetRead to get data from TinyURL + Added reverse TinyURL generation (Automatically turn TinyURL into long url & vice versa) + Added preliminary functions to support INI settings Edited February 26, 2011 by Foxhound [quote]Quick YouTube To MP3 | Lyrics Finder | Internet Radio Player | GetWeather | TinyURLifier[/quote] Link to comment Share on other sites More sharing options...
guinness Posted February 27, 2011 Share Posted February 27, 2011 (edited) Your strike me as a user that likes to strip Includes >> - Removed _InetGetSource() and implemented InetRead to get data from TinyURLSo with the _StringBetween() maybe you could use this >> $url = StringRegExp($data, '(?s)(?i)id="redirecturl" href="(.*?)">Proceed', 3) If Not @error Then Return $url[0] Return SetError(1, 1, False) Edited February 27, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Foxhound Posted February 27, 2011 Author Share Posted February 27, 2011 Your strike me as a user that likes to strip Includes >> So with the _StringBetween() maybe you could use this >> $url = StringRegExp($data, '(?s)(?i)id="redirecturl" href="(.*?)">Proceed', 3) If Not @error Then Return $url[0] Return SetError(1, 1, False) I'm a beginner when it comes to RegEx. Thanks for the suggestion. I have much to learn [quote]Quick YouTube To MP3 | Lyrics Finder | Internet Radio Player | GetWeather | TinyURLifier[/quote] Link to comment Share on other sites More sharing options...
guinness Posted March 1, 2011 Share Posted March 1, 2011 (edited) So you want to learn about SRE?! I hope you don't mind but currently you are retrieving the URL code (http://tinyurl.com/2ruvw7) using StringTrimLeft() which is great, but what happens when/if TinyURL starts to use another gTLD e.g. .info by using SRE we can strip the URL and retrieve the TinyURL code regardless of the domain. For example if TinyURL was to change to http://wewerecalledtinyurlbutnowwearenot.com/2ruvw7 then 2ruvw7 would still be retrieved.$sURL = StringRegExpReplace($sURL, '.*://.*?/(.*)', '\1')Example:Global $TinyURL = _GetTinyURLFromURL("http://www.autoitscript.com/autoit3/downloads.shtml") ConsoleWrite($TinyURL & @CRLF) ConsoleWrite(_GetURLFromTinyURL($TinyURL) & @CRLF) Func _GetTinyURLFromURL($sURL) Local $bRead = InetRead("http://tinyurl.com/api-create.php?url=" & $sURL) Local $sRead = BinaryToString($bRead) If StringLen($sRead) == 0 Then Return SetError(1, 0, 0) Return StringStripWS($sRead, 3) EndFunc ;==>_GetTinyURLFromURL Func _GetURLFromTinyURL($sURL) $sURL = StringRegExpReplace($sURL, '.*://.*?/(.*)', '\1') Local $bRead = InetRead("http://preview.tinyurl.com/" & $sURL) Local $sRead = BinaryToString($bRead) Local $aReturn = StringRegExp($sRead, '(?s)(?i)id="redirecturl" href="(.*?)">Proceed', 3) If Not @error Then Return StringStripWS($aReturn[0], 3) Return SetError(1, 0, 0) EndFunc ;==>_GetURLFromTinyURL Edited March 1, 2011 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now