1

I'm building an Automator workflow that parses a Dropbox "gallery" page containing Quicktime video files, and automatically builds "direct-download" links for each of the files. In the end, I want all the links to be generated into the body of a Mail.app message.

Basically, everything works as expected, except for the part where the new links are sent to a new Mail.app message. My problem is that the links are sent to the body of the message without newlines, so they all get concatenated into a single line, like this:

https://dl.dropbox.com/u/149705/stackexchange/20121209/stackexchange_automator_prob2.png

(Mail.app seems to be wrapping the concatenated string on the question-marks)

The oddest thing about this is that if I use a "Copy to Clipboard" action at the end of the workflow (instead of my send-to-Mail Applescript), I get totally different results when I paste the same clipboard contents into TextEdit vs. BBEdit.

The links seem to paste into TextEdit properly. However, the same clipboard, pasted into a plaintext BBEdit document, yields only the first link:

https://dl.dropbox.com/u/149705/stackexchange/20121209/stackexchange_automator_prob5.jpg

What could be causing these 3 entirely different behaviors from the exact same results of the "Get Link URLs" action?

4

3 に答える 3

0

その結果が得られる理由は、リンクが文字列のリストとして開始されますが、単一の文字列として mail.app に送信されているためです。

リンクの後にリターンを入れるだけで、これを修正するために特別なことをする必要はありません。

この単一の「Run applescript」アクションを使用して、すべての作業を実行します。

このスクリプトは、ファイル DL リンクのみを収集します。最後に返信を追加して、Mail.app に送信します。他のフォーマットは不要

    on run {input, parameters}

        set db_tag to "dl-web.dropbox.com/get"
        set myLinks to {}
        tell application "Safari"


            set thelinkCount to do JavaScript "document.links.length " in document 1
            repeat with i from 1 to thelinkCount

                set this_link to (do JavaScript "document.links[" & i & "].href" in document 1) as string

                if this_link contains db_tag then

--add the link with a carriage return on the end.

                    copy this_link & return to end of myLinks
                end if
            end repeat
        end tell


        tell application "Mail"
            activate
            make new outgoing message with properties {visible:true, content:"" & myLinks}
        end tell
    end run
于 2012-12-14T17:38:11.667 に答える
0

各アプリケーションは異なり、出力の形式を理解しているかどうかはわかりません。

あなたのAppleScript行動について:

AppleScript listデフォルトでは区切り文字が "" に設定されているため、空の文字列 "" からの強制は 1 行になります

目的の結果を得るには、次のように区切り文字をreturnまたはlinefeedに設定します。

on run {input}
    set {oTID, text item delimiters} to {text item delimiters, linefeed}
    set tContent to input as text
    set text item delimiters to oTID

    tell application "Mail"
        activate
        make new outgoing message with properties {visible:true, content:tContent}
    end tell
    return input
end run
于 2012-12-10T04:06:57.323 に答える
0

他のすべてのアクションを取り除き、ギャラリーの URL で myPage を更新します。

on run
    set myPage to "https://www.dropbox.com/sh/aaaaaaaaaaaaaaa/aaaaaaaaaa"
    set myLinks to do shell script "curl " & quoted form of myPage & " | grep -Eo 'https://www.dropbox.com/sh/[^/]*/[^/\"]*/[^\"]*' | sed s'/https:\\/\\/www.dropbox.com\\(.*\\)/https:\\/\\/dl.dropbox.com\\1?dl=1/g'"

    tell application "Mail"
        activate
        make new outgoing message with properties {visible:true, content:"" & myLinks}
    end tell
end run
于 2012-12-10T02:45:13.000 に答える