ptrack


Logs | Files | README | README | LICENSE | LICENSE | GitLab


1
commit 80828d387097b7cb4cefaaf30e650bd8febcd395
2
Author: Connor Etherington <[email protected]>
3
Date:   Fri Dec 15 23:39:54 2023 +0200
4
5
    Auto-Commit Update - 20231215
6
---
7
 PKGBUILD                           |   2 +-
8
 README.md                          |   2 +-
9
 dist/ptrack-2.0.1-py3-none-any.whl | Bin 0 -> 10147 bytes
10
 dist/ptrack-2.0.1-py311_0.tar.bz2  | Bin 0 -> 30047 bytes
11
 dist/ptrack-2.0.1.tar.gz           | Bin 0 -> 9514 bytes
12
 ptrack/__init__.py                 |   2 +-
13
 ptrack/main.py                     |  17 +++++++++++------
14
 ptrack/methods.py                  |  18 ++++++++++--------
15
 recipe/meta.yaml                   |   2 +-
16
 setup.py                           |   2 +-
17
 10 files changed, 26 insertions(+), 19 deletions(-)
18
19
diff --git a/PKGBUILD b/PKGBUILD
20
index 571a083..d9161c6 100644
21
--- a/PKGBUILD
22
+++ b/PKGBUILD
23
@@ -1,7 +1,7 @@
24
 # Maintainer: Connor Etherington <[email protected]>
25
 # ---
26
 pkgname=ptrack
27
-pkgver=2.0.0
28
+pkgver=2.0.1
29
 pkgrel=1
30
 pkgdesc="A simple CLI utility for asthetically tracking progress when copying, moving or downloading files."
31
 arch=(x86_64)
32
diff --git a/README.md b/README.md
33
index a3eb98b..466e124 100644
34
--- a/README.md
35
+++ b/README.md
36
@@ -3,7 +3,7 @@
37
 ### Welcome to ptrack, a powerful and user-friendly CLI utility for tracking the progress of your file operations.
38
 ### Designed to be concise, efficient and performance-optimized, ptrack works swiftly and accurately, while providing in-depth insight into the progress of the task at hand.
39
 
40
-*Version: 2.0.0*
41
+*Version: 2.0.1*
42
 
43
 ***
44
 
45
diff --git a/dist/ptrack-2.0.1-py3-none-any.whl b/dist/ptrack-2.0.1-py3-none-any.whl
46
new file mode 100644
47
index 0000000..6f34ce6
48
Binary files /dev/null and b/dist/ptrack-2.0.1-py3-none-any.whl differ
49
diff --git a/dist/ptrack-2.0.1-py311_0.tar.bz2 b/dist/ptrack-2.0.1-py311_0.tar.bz2
50
new file mode 100644
51
index 0000000..fa29433
52
Binary files /dev/null and b/dist/ptrack-2.0.1-py311_0.tar.bz2 differ
53
diff --git a/dist/ptrack-2.0.1.tar.gz b/dist/ptrack-2.0.1.tar.gz
54
new file mode 100644
55
index 0000000..866c65d
56
Binary files /dev/null and b/dist/ptrack-2.0.1.tar.gz differ
57
diff --git a/ptrack/__init__.py b/ptrack/__init__.py
58
index 7e46d28..ffe7eee 100644
59
--- a/ptrack/__init__.py
60
+++ b/ptrack/__init__.py
61
@@ -1,5 +1,5 @@
62
 import argparse
63
-version="2.0.0"
64
+version="2.0.1"
65
 
66
 parser = argparse.ArgumentParser(description='A simple CLI utility for asthetically tracking progress when copying or moving files.')
67
 parser.add_argument('-v', '--verbose', action='store_true', help='verbose output')
68
diff --git a/ptrack/main.py b/ptrack/main.py
69
index c7c6938..c6c6200 100644
70
--- a/ptrack/main.py
71
+++ b/ptrack/main.py
72
@@ -142,6 +142,16 @@ def run(process):
73
     return srcPaths
74
 
75
 
76
+def wipe():
77
+    sys.stdout.write("\033[F")
78
+    sys.stdout.write("\033[K")
79
+    sys.stdout.flush()
80
+    sys.stdout.write("\033[F")
81
+
82
+def wipe2():
83
+    sys.stdout.write("\033[F")
84
+    sys.stdout.flush()
85
+
86
 def download():
87
     console = Console()
88
     urls = sys.argv[1:]
89
@@ -185,12 +195,6 @@ def download():
90
                     task = progress.add_task("", total=100, file_size="0 KB", start=False)
91
 
92
                     if isMediaUrl(url):
93
-                        def wipe():
94
-                            sys.stdout.write("\033[F")  # Cursor up one line
95
-                            sys.stdout.write("\033[K")  # Clear to the end of line
96
-                            sys.stdout.flush()
97
-                            sys.stdout.write("\033[F")  # Cursor up one line
98
-
99
                         mediaDownload(url, progress, wipe)
100
                         continue
101
 
102
@@ -201,6 +205,7 @@ def download():
103
 
104
                 size = format_file_size(total_size_in_bytes)
105
 
106
+                wipe2()
107
                 with Progress(
108
                     BarColumn(bar_width=50),
109
                     "[progress.percentage]{task.percentage:>3.0f}%",
110
diff --git a/ptrack/methods.py b/ptrack/methods.py
111
index d72319e..b02ca96 100644
112
--- a/ptrack/methods.py
113
+++ b/ptrack/methods.py
114
@@ -14,12 +14,11 @@ from concurrent.futures import ThreadPoolExecutor
115
 import subprocess
116
 import shlex
117
 from functools import lru_cache
118
-
119
+import shlex
120
 
121
 console = Console()
122
 operation_cancelled = False
123
 
124
-
125
 def getTotalSize(srcPaths):
126
     total_size = 0
127
     for path in srcPaths:
128
@@ -187,13 +186,16 @@ class CustomDLColumn(FileSizeColumn, TimeElapsedColumn):
129
 
130
 
131
 def isMediaUrl(url):
132
-    command = shlex.split(f'yt-dlp --get-url {url}')
133
+    command = shlex.split(f'yt-dlp --get-filename -o "%(ext)s" {url}')
134
     try:
135
-        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
136
-        stdout, stderr = process.communicate()
137
-        return process.returncode == 0 and bool(stdout.strip())
138
+        process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
139
+        stdout, _ = process.communicate()
140
+        if process.returncode != 0:
141
+            return False
142
+
143
+        file_extension = stdout.decode().strip()
144
+        return file_extension in ["mp3", "mp4", "ogg", "webm", "mkv", "flv", "avi", "mov", "wmv"]
145
     except Exception as e:
146
-        print(f"Error checking URL type: {e}")
147
+        print(f"Error checking URL type with yt-dlp: {e}")
148
         return False
149
 
150
-
151
diff --git a/recipe/meta.yaml b/recipe/meta.yaml
152
index 0402787..b17f5d1 100644
153
--- a/recipe/meta.yaml
154
+++ b/recipe/meta.yaml
155
@@ -1,6 +1,6 @@
156
 package:
157
   name: ptrack
158
-  version: 2.0.0
159
+  version: 2.0.1
160
 
161
 source:
162
   path: ..
163
diff --git a/setup.py b/setup.py
164
index cf2e214..875d71d 100644
165
--- a/setup.py
166
+++ b/setup.py
167
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
168
 
169
 setup(
170
     name='ptrack',
171
-    version="2.0.0",
172
+    version="2.0.1",
173
     description='A simple CLI utility for asthetically tracking progress when copying, moving or downloading files.',
174
     author='Connor Etherington',
175
     author_email='[email protected]',