Jump to content
Ketarin forum

Import from template


Stalker
 Share

Recommended Posts

I think it would be a nice idea to have a forth option when creating a new app entry and that is "Import from template". That way there's a possibility to add more download sites then just FileHippo.

Template would be an XML similar to app entry XML but without application name. For example consider this for a template to Firefox Addons site (please note that it may not actually be functioning right now if you create your app entry based on this template but this is my best guess from 15 minutes of looking at how the site is structured :) Don't judge harshly. And because I could really remember HTMLs equivalents for < and > I assumed &qt; was < and < was >):

<?xml version="1.0" encoding="utf-16"?>
<Jobs>
 <ApplicationJob xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Guid="b5f78f98-af27-41ba-ac00-377321fdba96">
   <DownloadBeta>Default</DownloadBeta>
   <DownloadDate xsi:nil="true" />
   <CanBeShared>true</CanBeShared>
   <ShareApplication>false</ShareApplication>
   <HttpReferer />
   <Variables>
     <item>

       <key>
         <string>addon_id</string>
       </key>
       <value>
         <UrlVariable>
           <VariableType>StartEnd</VariableType>
           <Regex />
           <Url>https://addons.mozilla.org/en-US/firefox/search?q={appname:replace: :+}&cat=all</Url>
           <StartText>&qt;h3 class="name"<&qt;a href="/en-US/firefox/addon/</StartText>
           <EndText>" <</EndText>
           <Name>addon_id</Name>
         </UrlVariable>
       </value>

       <key>
         <string>version</string>
       </key>
       <value>
         <UrlVariable>
           <VariableType>StartEnd</VariableType>
           <Regex />
           <Url>https://addons.mozilla.org/en-US/firefox/addon/{addon_id}</Url>
           <StartText>title="Permanent link to this version"<</StartText>
           <EndText>&qt;/a<</EndText>
           <Name>version</Name>
         </UrlVariable>
       </value>

       <key>
         <string>link</string>
       </key>
       <value>
         <UrlVariable>
           <VariableType>StartEnd</VariableType>
           <Regex />
           <Url>https://addons.mozilla.org/en-US/firefox/addon/{addon_id}</Url>
           <StartText>&qt;p class="install-button platform-ALL"<
           &qt;a href="</StartText>
           <EndText>"</EndText>
           <Name>link</Name>
         </UrlVariable>
       </value>

       <key>
         <string>sha1</string>
       </key>
       <value>
         <UrlVariable>
           <VariableType>StartEnd</VariableType>
           <Regex />
           <Url>https://addons.mozilla.org/en-US/firefox/addon/{addon_id}</Url>
           <StartText>addonHash="</StartText>
           <EndText>"</EndText>
           <Name>sha1</Name>
         </UrlVariable>
       </value>

     </item>
   </Variables>
   <ExecuteCommand />
   <Category>Firefox Addon</Category>
   <SourceType>FixedUrl</SourceType>
   <PreviousLocation></PreviousLocation>
   <DeletePreviousFile>true</DeletePreviousFile>
   <Enabled>true</Enabled>
   <FileHippoId />
   <LastUpdated></LastUpdated>
   <TargetPath>{DEST_DIR}\{category}\{appname}_{version}.{url:ext}</TargetPath>
   <FixedDownloadUrl>https://addons.mozilla.com/{link}</FixedDownloadUrl>
   <Name>INSERT YOUR APPLICATION NAME HERE</Name>
 </ApplicationJob>
</Jobs>

 

Basically you insert the name of your addon and it will find the closest match on Firefox Addons site. It is a bit trickier then FileHippo due to the fact that you need to know addon ID (which is a number and has no visible relation to addon name) to download the addon and thus such computations. Automatic retrieval of ID can be done in the same way Ketarin now handles FileHippo (paste a link and parse the ID from there) but I don't know how to do it in a generic way (maybe with some heavy use of regex) so currently the example contains flaky variable way.

Same templates can be added for other sites, like even FileHippo instead of having its own entry in the Add app dialog, to make Ketarin more robust.

Edited by Stalker
Link to comment
Share on other sites

Stalker,

 

This is one of the items on 'my wish list of feature requests' that I intended to request in the future... possibly post version 1.0 or so as Florian has his hands fairly full at the present... ;) In the meantime, I am creating the 'site templates' by manually editing an existing single app's entry that I exported, (i.e. as for SnapFiles.com); I created a template named SnapFiles_Template.xml. I am trying to find the time to create a Tutorial regarding this in the 'Tips and Tutorials' forum... possibly next week. ;) There is one entry that must be removed in the exported XML to create the template... (i.e. the Guid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" entry on the 'ApplicationJob' line) and the 'LastUpdated' entry must be changed to <LastUpdated xsi:nil="true" /> if you downloaded the app prior to creating the template). I use PSPad (freeware) to edit the exported XML. Once you develop regular expressions that are consistent on a particular site this can be done easily and makes life much easier! :D There are a couple of other issues that I will attempt to address in the tutorial. Hope this helps in the meantime.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.