From 1c085aa24b751e5ac3a105ebf8df8519e16549fc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Odd=20Str=C3=A5b=C3=B8?= <oddstr13@openshell.no>
Date: Sun, 17 Oct 2021 22:40:34 +0200
Subject: [PATCH] Improve build exclusion filter

---
 build.py | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/build.py b/build.py
index 7d73f092..bf449524 100755
--- a/build.py
+++ b/build.py
@@ -82,17 +82,33 @@ def file_filter(file_name: str) -> bool:
     """
     True if file_name is meant to be included
     """
-    return 'plugin.video.jellyfin' not in file_name and 'pyo' not in file_name
+    return (
+        not (file_name.startswith('plugin.video.jellyfin') and file_name.endswith('.zip'))
+        and not file_name.endswith('.pyo')
+        and not file_name.endswith('.pyc')
+        and not file_name.endswith('.pyd')
+    )
 
 
 def folder_filter(folder_name: str) -> bool:
     """
     True if folder_name is meant to be included
     """
-    return ('.ci' not in folder_name
-            and '.git' not in folder_name
-            and '.github' not in folder_name
-            and '.build' not in folder_name)
+    filters = [
+        '.ci',
+        '.git',
+        '.github',
+        '.build',
+        '.mypy_cache',
+        '.pytest_cache',
+        '__pycache__',
+    ]
+    for f in filters:
+        if f in folder_name.split(os.path.sep):
+            return False
+
+    return True
+
 
 
 if __name__ == '__main__':