diff --git a/ruterstop.py b/ruterstop.py
index 1ad7ea5..8475531 100644
--- a/ruterstop.py
+++ b/ruterstop.py
@@ -161,6 +161,8 @@ def main(argv, *, stdout=sys.stdout):
                      help="find stops at https://stoppested.entur.org (guest:guest)")
     par.add_argument('--direction', choices=["inbound", "outbound"],
                      help="filter direction of departures")
+    par.add_argument('--min-eta', type=int, default=0,
+                     help="minimum ETA of departures to return")
     par.add_argument('--server', action="store_true",
                      help="start a HTTP server")
     par.add_argument('--host', type=str, default="0.0.0.0",
@@ -186,19 +188,27 @@ def main(argv, *, stdout=sys.stdout):
     else:
         directions = [args.direction]
 
+    def get_departures():
+        raw_stop = get_cached_realtime_stop(stop_id=args.stop_id)
+        deps = parse_departures(raw_stop)
+
+        # Filter departures with minimum time treshold
+        treshold = datetime.now() + timedelta(minutes=args.min_eta)
+
+        return [d for d in deps if d.eta >= treshold]
+
     if args.server:
         @bottle.route("/")
         def _():
-            raw_stop = get_cached_realtime_stop(stop_id=args.stop_id)
-            deps = parse_departures(raw_stop)
+            deps = get_departures()
             return '\n'.join([str(d) for d in deps if d.direction in directions])
 
         bottle.run(host=args.host, port=args.port)
 
     # Otherwise print out stop information and exit
     else:
-        raw_stop = get_cached_realtime_stop(stop_id=args.stop_id)
-        for dep in parse_departures(raw_stop):
+        deps = get_departures()
+        for dep in deps:
             print(dep, file=stdout)
 
 

Sett en justerbar minstegrense for tid til neste avgang
Dersom det tar 2 minutter å gå til stoppestedet er jeg ikke interessert i å se de som går om 0 min
diff --git a/tests/test_ruterstop.py b/tests/test_ruterstop.py
index a95aefc..5368631 100644
--- a/tests/test_ruterstop.py
+++ b/tests/test_ruterstop.py
@@ -173,3 +173,12 @@ class CommandLineInterfaceTestCase(unittest.TestCase):
 
             actual = filter(None, stdout.getvalue().split('\n')) # remove empty lines
             self.assertEqual(list(actual), self.expected_output)
+
+    def test_adjustable_minimum_time(self):
+        stdout = StringIO()
+
+        with freeze_time(self.first_departure_time):
+            # Call CLI with custom args
+            api.main([None, "--stop-id", "1337", "--min-eta", "2"], stdout=stdout)
+            lines = filter(None, stdout.getvalue().split('\n')) # remove empty lines
+            self.assertEqual(list(lines), self.expected_output[3:]) # skip first 3

pip install -e .
parse_log_pytest
requirements.txt
pytest
apt-get update apt-get install -y gcc
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
bottle==0.13.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
coverage==7.2.7
exceptiongroup==1.2.2
freezegun==1.5.1
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
python-dateutil==2.9.0.post0
requests==2.31.0
-e git+https://github.com/stigok/ruterstop.git@eb7d8dc468a37e2ad08f8e7f50b6d02c46f6bd62#egg=ruterstop
six==1.17.0
tomli==2.0.1
typing_extensions==4.7.1
urllib3==2.0.7
zipp==3.15.0

name: ruterstop
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - bottle==0.13.2
      - charset-normalizer==3.4.1
      - coverage==7.2.7
      - exceptiongroup==1.2.2
      - freezegun==1.5.1
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - packaging==24.0
      - pluggy==1.2.0
      - pytest==7.4.4
      - python-dateutil==2.9.0.post0
      - requests==2.31.0
      - six==1.17.0
      - tomli==2.0.1
      - typing-extensions==4.7.1
      - urllib3==2.0.7
      - zipp==3.15.0
prefix: /opt/conda/envs/ruterstop

tests/test_ruterstop.py::CommandLineInterfaceTestCase::test_adjustable_minimum_time
tests/test_ruterstop.py::HumanDeltaTestCase::test_default_kwarg_value tests/test_ruterstop.py::HumanDeltaTestCase::test_output tests/test_ruterstop.py::DepartureClassTestCase::test_str_representation tests/test_ruterstop.py::RuterstopTestCase::test_get_realtime_stop tests/test_ruterstop.py::RuterstopTestCase::test_norwegian_ascii tests/test_ruterstop.py::RuterstopTestCase::test_parse_departures tests/test_ruterstop.py::RuterstopTestCase::test_timed_cache tests/test_ruterstop.py::CommandLineInterfaceTestCase::test_simple_output
ruterstop.py
ruterstop.py