omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    ios Shortcut not showing/calling console.alert

    Pythonista
    4
    7
    1437
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • funnymanva
      funnymanva last edited by

      I have installed Stash and have a Python script I’ve used for a long time to download audio or audio/video from Youtube with the youtube_dl library. It is launched from a Shortcut and has worked for a while. I’ve noticed at some point, not sure which iOS version or when, but now when I use the Shortcut it doesn’t seem to work at all. The first thing in the script is a console.alert that asks the user if they want to download audio/video or audio only. This doesn’t pop up at all. I’m using the right pythonista3 URL as if I copy the URL of a YT video and click the pythonista3:// url in a note where I have it saved it works completely fine. From Shortcuts it shows a little box on the top of the screen (this is an iPad Pro 2018) that says “scripting” I believe and then it just disappears. It obviously doesn’t download the video or anything since it never even seemed to run the console.alert. Did something change and I have to update this script? I’ll include it below., but it’s not very complicated. The end of the script opens the folder where the file is downloaded to. All this works running directly after copying a YT URL into the clipboard. I just can’t figure out why not from Shortcuts.

      from __future__ import unicode_literals
      import youtube_dl
      import clipboard
      import console
      import shortcuts
      
      link = clipboard.get()
      
      mediaformat = console.alert('Choose Format', '', 'Video/Audio', 'Audio Only', hide_cancel_button=True)
      
      if mediaformat == 1:
          ydl_opts = {
              'outtmpl': 'youtube_dl/%(title)s.%(ext)s'
          }
      else:
          ydl_opts = {
      	    'outtmpl': 'youtube_dl/%(title)s.%(ext)s',
      	    'format': 'bestaudio[ext=m4a]'
          }
      with youtube_dl.YoutubeDL(ydl_opts) as ydl:
          info = ydl.extract_info(link, download=True)
          title = info.get('title')
      
      shortcuts.open_url('shareddocuments:////private/var/mobile/Library/Mobile%20Documents/iCloud~com~omz-software~Pythonista3/Documents/youtube_dl')
      
      
      funnymanva 1 Reply Last reply Reply Quote 0
      • funnymanva
        funnymanva @funnymanva last edited by

        Just some additional information.z I took everything out and just did the console.alert and it still doesn’t pop up.

        cvp mikael 2 Replies Last reply Reply Quote 0
        • cvp
          cvp @funnymanva last edited by

          @funnymanva try via a def decorated so :

                  @ui.in_background
                  def alert():
                      console.alert('test')
          
          funnymanva 1 Reply Last reply Reply Quote 0
          • mikael
            mikael @funnymanva last edited by

            @funnymanva, also, would suggest making that selection in Apple Shortcut.

            1 Reply Last reply Reply Quote 1
            • funnymanva
              funnymanva @cvp last edited by

              @cvp I tried this and no difference. It’s odd that these all used to work at some point. I’ve also noticed if I just assume always audio it doesn’t download the audio from YT. It’s like it doesn’t run it properly.

              1 Reply Last reply Reply Quote 0
              • funnymanva
                funnymanva last edited by

                Ok, so the change must have been in Shortcuts. It wasn’t running the URL just making it so it would go to the next step. I guess they changed that function and my Shortcut I hadn’t touched in forever. I changed the shortcut to Safari’s Open URL and now it works. I did take the suggestion to prompt for Audio/Video or just Audio in Shortcuts and pass that as an argument. Sorry I couldn’t figure out why it just broke.

                1 Reply Last reply Reply Quote 1
                • Broussard_241
                  Broussard_241 last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  Powered by NodeBB Forums | Contributors