• jaalburquerque

    Thank you for the information. I am working with HTML and I may need to reduce it to plain text for easy searching and processing later. The information is useful if I should need to reduce the HTML to plain text. Thanks again.

    posted in Pythonista read more
  • jaalburquerque

    Yes, that helps. Thanks so much.

    posted in Pythonista read more
  • jaalburquerque

    Hello everyone. I have some html in a string that I would like to display (rendered, not as plain text). Would someone know a quick and easy way to do this using Pythonista? I would really appreciate it. Thanks so much.

    posted in Pythonista read more
  • jaalburquerque

    Thanks for taking the time to answer the question that I had. Thanks for the information. Have a good day.

    posted in Pythonista read more
  • jaalburquerque

    Hello. I was able to write a preliminary version of the script to play the audio files. The script is designed to play audio files contained in a directory in the file system. It assumes that all of the files in the specified directory are audio files. It uses the “FolderPicker” class mentioned in the other topic that I opened asking how to allow the user to select a directory in the file system [1]. I am attaching the script below. The script plays the audio files fine when I run it in the Pythonista app, but when I minimize the app, the audio stops playing. I would like the audio to continue playing even if the app is minimized and I use other apps. Would anyone know if this is possible?

    [1] https://forum.omz-software.com/topic/7506/allowing-the-user-to-select-a-directory-from-the-file-system

    Note: I edited the original post to move the [1] reference directly below the paragraph that references it. Also, I added a change to the script to make it runnable using a pythonista URL scheme, for example “pythonista://PlayAudioDirectory?action=run&argv=audio_directory

    PlayAudioDirectory.py:

    import sys
    import re
    import dialogs
    import FolderPicker
    from pathlib import Path
    import sound
    import time
    
    IPHONE_VOLUME_PATH = '/private/var/mobile/Containers/Shared/AppGroup/193D444B-2870-447A-A797-33D935C572B3/File Provider Storage'
    ICLOUD_VOLUME_PATH = '/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs'
    
    audioDirectory = None
    
    if len(sys.argv) > 1:
      audioDirectory = sys.argv[1]
      audioDirectory = re.sub(r'^On My iPhone', IPHONE_VOLUME_PATH, audioDirectory)
      audioDirectory = re.sub(r'^iCloud Drive', ICLOUD_VOLUME_PATH, audioDirectory)
    else:
      volume = None
    
      volumerChoice = dialogs.list_dialog('Select location of directory', ['This iPhone', 'iCloud'])
      if volumerChoice == 'This iPhone':
        volume = IPHONE_VOLUME_PATH
      elif volumerChoice == 'iCloud':
        volume = ICLOUD_VOLUME_PATH
        
      if volume != None:
        audioDirectory = FolderPicker.folder_picker_dialog('Please select the audio folder', root_dir = volume)
    
    if audioDirectory != None:
      audioPath = Path(audioDirectory)
      for child in sorted(audioPath.iterdir()):
        audioFilename = str(child.resolve())
        player = sound.Player(audioFilename)
        duration = player.duration
        player.play()
        time.sleep(duration)
    

    posted in Pythonista read more
  • jaalburquerque

    Okay. It is very clear. Thanks again.

    posted in Pythonista read more
  • jaalburquerque

    Okay. I will try that. Thanks so much.

    posted in Pythonista read more
  • jaalburquerque

    Thanks. And would you be able to tell me how I might use the “FolderPicker” script in my own script to open a directory either “On My iPhone” or on the iCloud Drive?

    posted in Pythonista read more
  • jaalburquerque

    Would any of you know if it is possible to open a folder that is contained in the iPhone file system (“On My iPhone”) or in the iCloud Drive to play the audio files in that folder? The audio files are located in directories in both these locations.

    posted in Pythonista read more
  • jaalburquerque

    Thanks again for your help. Have a good day again.

    posted in Pythonista read more
  • jaalburquerque

    Hello. I have begun writing a small script to play audio files contained in a certain directory (on the iCloud or in the iPhone file system). For this, I would like to allow the user to select the directory that contains the audio files. Looking at the documentation, I found that dialogs.pick_document() allows the user to select files from the file system. But when I test it, the dialog does not allow for a directory to be selected, only regular files. What I would like is for the user to be able to select a directory. It seems that if the right UTI is specified, this could be possible. I tried using the ‘public.directory’ and ‘public.folder’ types, but the dialog still does not allow me to select a directory. Would anyone have any idea as to what I need to do to allow the user to select a directory from the file system? I would really appreciate it.

    posted in Pythonista read more
  • jaalburquerque

    Thanks so much. Very helpful information. Have a good day.

    posted in Pythonista read more
  • jaalburquerque

    Hello everyone. I am planning to write a short script to play a list of audio files in order. I was thinking of using the sound.play_effect() function because I would like the audio to play without blocking other audio from other apps from playing. I wonder if this is a good idea. If it is, I am also wondering if there would be a way to know when an effect has finished playing. This would allow me to play the audio files in order, one after another. If using sound.play_effect() would not be recommended, I am willing to use the sound.Player class. I would just like to be able to play the audio, allowing audio from other apps to be played also. Would anyone have any recommendations for me? I would greatly appreciate it. Thanks so much.

    posted in Pythonista read more
  • jaalburquerque

    @cvp Okay. I believe that you have both given me enough information and exemplification to achieve what I am trying to do. I believe that the code particularly will be very useful to me. Thank you both very much.

    posted in Pythonista read more
  • jaalburquerque

    @JonB Thanks for the reply. Would changing the tint color make it possible to display multicolored text? I would prefer something like an alert, but I would use a dialog if it allows displaying the text in a mixture of various colors.

    posted in Pythonista read more
  • jaalburquerque

    I’m wondering if it is possible to use something like console.alert() to show the user some text rendered in different colors. Would someone have an idea as to how to achieve this as simply and easily as possible? I would really appreciate it. Thanks so much for taking the time to answer.

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!