Changeset 4668


Ignore:
Timestamp:
May 10, 2017, 1:35:05 PM (2 years ago)
Author:
Juanma
Message:

Added ubuntu screenshots

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devtools/desktop_to_xml/desktop_to_xml.sh

    r4648 r4668  
    2828msg_select_pkg="\nSelect the name of the package to process\n"
    2929msg_desktop_not_found="\nDesktop file not found at %s. Process aborted.\n"
    30 msg_searching_img="\nSearching screenshots...\n"
     30msg_searching_img="\nSearching screenshots in %s...\n"
    3131msg_image_found="\nScreenshoot %s finded for app %s\n"
    3232function usage_help
     
    163163        [ -z $index ] && index=0
    164164        installDir=${installDir/\**/}
    165         [ -z $installDir ] && installDir='.'
     165        [ -z "$installDir" ] && installDir='.'
    166166        process_pkg $installDir
    167167}
     
    227227                        printf("") > outFile
    228228                        xmlFile=metainfoDir"/"array[1]".appdata.xml"
     229                        print "XML: "xmlFile
    229230                        print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > xmlFile
    230231                        print "<component type=\"desktop-application\">" >> xmlFile
     
    364365function get_screenshot
    365366{
    366         printf "$msg_searching_img"
     367        printf "$msg_searching_img" "debian"
    367368        imageFound=0
    368369        pkgName=${1/.desktop/}
    369370        url="https://screenshots.debian.net/packages?page=1&search=${pkgName}&utf8=✓"
     371        get_screenshot_from $url $pkgName
     372        if [[ $imageFound == 0 ]]
     373        then
     374                printf "$msg_searching_img" "ubuntu"
     375                url="http://screenshots.ubuntu.com/packages?page=1&search=${pkgName}&utf8=✓"
     376                get_screenshot_from $url $pkgName
     377        fi
     378
     379}
     380
     381function get_screenshot_from
     382{
     383        url=$1
     384        baseUrl=${url/packages*/}
     385        pkgName=$2
    370386        outFile=$(mktemp)
    371         wget  $url -o /dev/null -O $outFile
     387        wget $url -t 2 -T 10 -o /dev/null -O $outFile
    372388        if [ $? -eq 0 ]
    373389        then
     
    377393                        searchResult=${searchResult/href=\"\//}
    378394                        searchResult=${searchResult/\"/}
    379                         url="https://screenshots.debian.net/${searchResult}"
    380                         wget  $url -o /tmp/log -O $outFile
     395                        url=${baseUrl}${searchResult}
     396                        wget $url -t 2 -T 10 -o /tmp/log -O $outFile
    381397                        if [ $? -eq 0 ]
    382398                        then
     
    384400                                imageFound=${imageFound/href=\"\//}
    385401                                imageFound=${imageFound/\"/}
    386                                 imageFound="https://screenshots.debian.net/${imageFound}"
     402                                imageFound=${baseUrl}${imageFound}
    387403                                printf "$msg_image_found" $imageFound $pkgName
    388404                        fi
Note: See TracChangeset for help on using the changeset viewer.