Download links from Instapaper to instapaper text format

This script download only links from Instapaper that is on Instapaper text format.
The script is very customizable so you can choose the rules you want, to download from any site.

If you want to download all text format links from Instapaper, just type http for the keyword…

Just capture a web page from your Instapaper account so you can see the links you have there.

Choose that file and run this script to collect all the links from that captured page.

After you have download the text format links you want to DT, then mark all the links you downloaded and choose from the DT script menu:

Rename -> “To Web Page Title” to rename all the name of the links to their correct name :smiley:

--Download only links with the searched result from Instapaper (Text) 
--if download contain something with google it exclude the actual search result
--By Nexus 2011-05-13

property search_string : ""

tell application id "com.devon-technologies.thinkpro2"
	activate
	set theSelection to the selection
	if theSelection is not {} then
		set downloadstate to false
		set downloadStatus to false
		try
			repeat
				set search_string to display name editor "Type any keywords you want to download only"
				if search_string is not "" then exit repeat
			end repeat
			
			show progress indicator "Searching links to download......" steps (count of theSelection) with cancel button
			
			repeat with theRecord in theSelection
				set this_URL to the URL of theRecord
				set this_source to the source of theRecord
				set these_links to get links of this_source base URL this_URL
				step progress indicator theSelection
				
				show progress indicator "Searching links to download..." steps (count of theRecord) with cancel button
				repeat with this_link in these_links
				---- Here you can customize what type of content you want to download -----
					if the this_link contains "http://www.google" or the this_link contains "http://74.125.77.132" or the this_link contains "http://translate.google" or the this_link contains "google.se" or the this_link contains "google.com" or the this_link contains "search.php" or the this_link contains "index.php" or the this_link contains ".php?" or the this_link contains ".cgi?" or the this_link contains "/move/" or the this_link contains "/edit/" or the this_link contains "/skip" or the this_link contains "/delete" or the this_link contains "/star_toggle/" then
						set downloadStatus to false
					else
						if (the this_link contains search_string) and the this_link contains "article=" then
							
							set downloadstate to true
							set downloadStatus to true
						end if
					end if
					if downloadStatus is true then
						add download this_link referrer this_URL without automatic
					else
						if downloadStatus is false then
						end if
					end if
					step progress indicator (name of theRecord) as string
					
				end repeat
				
				if cancelled progress then
					hide progress indicator
					return
				end if
			end repeat
			hide progress indicator
			
			
			if downloadstate is false then
				display dialog "Couldn't find any files containing the keywords"
			end if
			
		on error error_message number error_number
			hide progress indicator
			if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
		end try
	end if
end tell