Jump to content

JustWatch - Alfred Workflow


Recommended Posts

16 hours ago, edbro said:

Yes, 100% for Unbelievable. If I type slowly, I get hits on "U", more hits on "UN" and it errors when I get to "UNB".

 

Thanks! Found the problem and it's fixed. 

You can wait for the workflow to auto-update (in max 2 days) or get the latest release (1.0.5, for now) from here https://github.com/vinaywadhwa/justwatch-alfred/releases .

 

If you are interested in more details

- The "API" this workflow uses (justwatch) sends some bad data for some titles. 

- The workflow now expects and handles the bad data better in the latest release (1.0.5, just released), all thanks to your report 👏🏼 

 

 

Link to comment
  • 2 years later...

Hello @designjoe

I'm working on this. Here's an updated version of the workflow that uses python3 that seems to be working for me but doesn't work for another user. Would you mind giving it a go? 

 

You can follow the progress on this GitHub issue https://github.com/vinaywadhwa/justwatch-alfred/issues/8

@vitor could use some help, if you'd be kind enough to take a look at the discussion in the GitHub issue.

Edited by Vinay W
Link to comment

Since it was the lingering question on GitHub, long story short on the Python 3 situation:

 

macOS comes with /usr/bin/python3 but it’s a shim, so Python isn’t really there. But as soon as you call it the first time, macOS will present the user with a GUI dialog asking them to install the Developer Tools. It takes two clicks (and waiting for a progress bar) and it’s done. From that point on, /usr/bin/python3 will point to a real Python 3 runtime (mind the version; it’s a few years behind the latest). People with Homebrew installed already have the Developer Tools, so it’ll just work.

 

My recommendation is to test against  /usr/bin/python3 (because it’s the lowest version users will have access to without configuration) but use python3 (not the full path) in the Workflow as it will be more flexible against future Apple shenanigans.

Link to comment

@vitor thanks for taking the time to answer. Appreciate it. 

 

Just to confirm if i understand the reasoning behind your suggestion to use python3 (instead of fully qualified `/usr/bin/python3`):
- so we're basically betting on the user not messing with the `PATH` (and keeping python3 on it) 
- ... instead of a situation where apple removes the shim -> Alfred users having to install python3 themselves and the path could differ depending on the manual installation method?

In that case, i'm leaning towards going with `/usr/bin/python3` (instead of `python3`) because that is most certain to work right now with the least friction for most users. And update if/when the time comes.

 

Another Side question : In case you know, have we ever considered bundling a python environment with the Alfred app? Since many workflows rely on it? Especially now with the bundling mess?

 

 

Link to comment
1 hour ago, Vinay W said:

In that case, i'm leaning towards going with `/usr/bin/python3` (instead of `python3`) because that is most certain to work right now with the least friction for most users. And update if/when the time comes.

In Alfred environment /usr/bin/python3 is the same of python3. You don’t need the full path.

Edited by xilopaint
Link to comment
3 hours ago, Vinay W said:

so we're basically betting on the user not messing with the `PATH`

 

Alfred uses its own PATH setting, it won’t be influenced by the user unless they deliberately change the Workflow. My recommendation stands (see also @xilopaint’s answer).

 

3 hours ago, Vinay W said:

have we ever considered bundling a python environment with the Alfred app?

 

As explained on another post:

 

Quote

Shipping a Python 3 installation means maintaining it, including in two architectures, plus every other language (why is Python special?). It means bloating the Alfred distribution, debugging a bunch of runtimes, keep up-to-date with every version change, handle deprecations, handle every request for every niche or hard to embed language…
 
Apple—literally the richest company in the world—decided that was too much of a hassle to keep doing even when they were making a subpar job at it, and you’re suggesting Alfred’s development essentially grinds to a halt replicating the scenario.

 

The last part doesn’t apply to your query (you posed a question; the answer above was to someone suggesting it would be trivial) but it should answer your question.

 

By the way, added your fork to the table as an alternative to the original.

Link to comment
  • 6 months later...

Updated to version 1.1.2 today, stopped working. Here's the debug info. I'm on Monterey 12.6.1, BTW

 

[21:32:33.388] JustWatch - Alfred[Script Filter] Queuing argument 'class action'
[21:32:37.802] JustWatch - Alfred[Script Filter] Script with argv '(null)' finished
[21:32:37.807] ERROR: JustWatch - Alfred[Script Filter] Code 1: .
.
21:32:33 workflow.py:2093 DEBUG    ---------- JustWatch - Alfred (1.1.2) ----------
name 'FakeUserAgentError' is not defined
Traceback (most recent call last):
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/lib/agent/utils.py", line 154, in load
    for item in get_browsers(verify_ssl=verify_ssl):
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/lib/agent/utils.py", line 99, in get_browsers
    html = html.split('<table class="w3-table-all notranslate">')[1]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/lib/agent/utils.py", line 64, in get
    with contextlib.closing(urlopen(
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 214, in urlopen
    return opener.open(url, data, timeout)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 523, in open
    response = meth(req, response)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 632, in http_response
    response = self.parent.error(
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 561, in error
    return self._call_chain(*args)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 494, in _call_chain
    result = func(*args)
  File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 641, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 503: Service Unavailable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/workflow/workflow.py", line 2107, in run
    func(self)
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/main.py", line 111, in main
    from justwatch import JustWatch
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/./lib/justwatch/__init__.py", line 1, in <module>
    from .justwatchapi import JustWatch
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/./lib/justwatch/justwatchapi.py", line 7, in <module>
    HEADER = {'User-Agent': UserAgent().random}
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/lib/agent/agent.py", line 69, in __init__
    self.load()
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/lib/agent/agent.py", line 75, in load
    self.data = load_cached(
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/lib/agent/utils.py", line 250, in load_cached
    update(path, use_cache_server=use_cache_server, verify_ssl=verify_ssl)
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/lib/agent/utils.py", line 245, in update
    write(path, load(use_cache_server=use_cache_server, verify_ssl=verify_ssl))
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/lib/agent/utils.py", line 187, in load
    ret = json.loads(get(
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.DCB3A622-517D-4C6F-9F01-320187C90FD9/lib/agent/utils.py", line 84, in get
    raise FakeUserAgentError('Maximum amount of retries reached')
NameError: name 'FakeUserAgentError' is not defined
[21:32:37.810] JustWatch - Alfred[Script Filter] {
  "items": [
    {
      "title": "Error in workflow 'JustWatch - Alfred'",
      "subtitle": "name 'FakeUserAgentError' is not defined",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}

 

Link to comment
  • 2 weeks later...

@Vinay W I updated to latest version v1.1.2 of this workflow but still following error message:

 

line 84, in get
    raise FakeUserAgentError('Maximum amount of retries reached')
NameError: name 'FakeUserAgentError' is not defined
[06:21:44.902] JustWatch - Alfred[Script Filter] {
  "items": [
    {
      "title": "Error in workflow 'JustWatch - Alfred'",
      "subtitle": "name 'FakeUserAgentError' is not defined",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}

 

Request you to kindly look into this.

Link to comment
  • 3 months later...

I found the latest version on the author's Github page. Installed it, but now I'm getting a different error message. Here's the debug info:

 

[14:23:23.623] JustWatch - Alfred[Script Filter] Queuing argument 'bat'
[14:23:23.800] JustWatch - Alfred[Script Filter] Script with argv '(null)' finished
[14:23:23.803] ERROR: JustWatch - Alfred[Script Filter] Code 1: .
.
14:23:23 workflow.py:2093 DEBUG    ---------- JustWatch - Alfred (1.1.3) ----------
No module named 'importlib_resources'
Traceback (most recent call last):
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/workflow/workflow.py", line 2107, in run
    func(self)
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/main.py", line 111, in main
    from justwatch import JustWatch
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/justwatch/__init__.py", line 1, in <module>
    from .justwatchapi import JustWatch
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/justwatch/justwatchapi.py", line 5, in <module>
    from lib.agent.agent import UserAgent
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/lib/agent/__init__.py", line 1, in <module>
    from agent.agent import FakeUserAgent, UserAgent  # noqa # isort:skip
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/agent/__init__.py", line 1, in <module>
    from agent.agent import FakeUserAgent, UserAgent  # noqa # isort:skip
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/agent/agent.py", line 7, in <module>
    from agent.utils import load, load_cached, str_types, update
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/agent/utils.py", line 16, in <module>
    import importlib_resources as ilr
ModuleNotFoundError: No module named 'importlib_resources'
[14:23:23.805] JustWatch - Alfred[Script Filter] {
  "items": [
    {
      "title": "Error in workflow 'JustWatch - Alfred'",
      "subtitle": "No module named 'importlib_resources'",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}
[14:23:25.613] JustWatch - Alfred[Script Filter] Queuing argument 'batman'
[14:23:25.787] JustWatch - Alfred[Script Filter] Script with argv '(null)' finished
[14:23:25.792] ERROR: JustWatch - Alfred[Script Filter] Code 1: .
.
14:23:25 workflow.py:2093 DEBUG    ---------- JustWatch - Alfred (1.1.3) ----------
No module named 'importlib_resources'
Traceback (most recent call last):
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/workflow/workflow.py", line 2107, in run
    func(self)
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/main.py", line 111, in main
    from justwatch import JustWatch
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/justwatch/__init__.py", line 1, in <module>
    from .justwatchapi import JustWatch
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/justwatch/justwatchapi.py", line 5, in <module>
    from lib.agent.agent import UserAgent
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/lib/agent/__init__.py", line 1, in <module>
    from agent.agent import FakeUserAgent, UserAgent  # noqa # isort:skip
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/agent/__init__.py", line 1, in <module>
    from agent.agent import FakeUserAgent, UserAgent  # noqa # isort:skip
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/agent/agent.py", line 7, in <module>
    from agent.utils import load, load_cached, str_types, update
  File "/Users/UserName/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.A40245FC-A839-4A28-B663-9A839F36895A/./lib/agent/utils.py", line 16, in <module>
    import importlib_resources as ilr
ModuleNotFoundError: No module named 'importlib_resources'
[14:23:25.793] JustWatch - Alfred[Script Filter] {
  "items": [
    {
      "title": "Error in workflow 'JustWatch - Alfred'",
      "subtitle": "No module named 'importlib_resources'",
      "valid": false,
      "icon": {
        "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
      }
    }
  ]
}

 

worklow error.png

Link to comment

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
×
×
  • Create New...