Ver código fonte

add regex to select query

Tobias Simetsreiter 1 ano atrás
pai
commit
300360d248
3 arquivos alterados com 43 adições e 47 exclusões
  1. 23 4
      filtergource.sh
  2. 14 1
      multigource.py
  3. 6 42
      multigource.sh

+ 23 - 4
filtergource.sh

@@ -3,17 +3,36 @@
 OUTPUT="$1"
 shift
 
+if [ -z "${GOURCE}" ]; then
+  GOURCE="$(which gource)"
+  if [ -z "${GOURCE}" ]; then
+    echo "Gource not set or found!"
+    exit 1
+  fi
+fi
+
+if [ -z "${FFMPEG}" ]; then
+  FFMPEG="$(which ffmpeg)"
+  if [ -z "${ffmpeg}" ]; then
+    echo "FFMpeg not set or found!"
+    exit 1
+  fi
+fi
+
 GOURCE_OPTS=(
     "--stop-at-end"
     "-s" "0.05" "--highlight-users" "--log-format" "custom"
     "-1920x1080" 
    #  "--start-date" "2010-01-01" 
-    "--file-idle-time" "0" "--no-vsync"
-    "--key" "--output-ppm-stream" "-"  "--output-framerate" "60" "-"
+    "--file-idle-time" "0" "--no-vsync" "--key"
+    "--output-ppm-stream" "-" "--output-framerate" "60"
+    "-"
     "--hide" "bloom,mouse,progress,filenames"
     "--auto-skip-seconds" ".01" "--multi-sampling"
 )
 
 cat |
-    gource "${GOURCE_OPTS[@]}" |
-    ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -b:v 10000000 -vcodec libx265 -crf 24 "$OUTPUT"
+    $GOURCE "${GOURCE_OPTS[@]}" |
+    $FFMPEG -y -r 60 -probesize 22023 -f image2pipe -vcodec ppm -i - -b:v 10000000 -vcodec libx265 -crf 24 "$OUTPUT"
+
+    # ffmpeg -y -r 60 -f rawvideo -pixel_format argb -video_size 1920x1080 -i - -b:v 10000000 -vcodec libx264 -crf 24 "$OUTPUT"

+ 14 - 1
multigource.py

@@ -80,6 +80,8 @@ def parser():
     p_select.add_argument('--repo-like', default=None, type=str)
     p_select.add_argument('--file-like', default=None, type=str)
     p_select.add_argument('--user-like', default=None, type=str)
+    p_select.add_argument('--user-regex', default=None, type=str)
+    p_select.add_argument('--user-overwrite', default=None, type=str)
     p_select.set_defaults(func=select)
     return p
 
@@ -188,9 +190,18 @@ def select(args: Namespace):
     import sqlite3
     import os
     with sqlite3.connect(args.output) as db:
+        import re    
+        def regexp(y, x, search=re.search):
+            return 1 if search(y, x) else 0
+        db.create_function('regexp', 2, regexp)
+
         STMT = STMT_SELECT
         ARGS = []
         WHERE_VERB = "WHERE"
+        if args.user_regex:
+            STMT += " "+WHERE_VERB+" user.name REGEXP ? "
+            ARGS.append(args.user_regex)
+            WHERE_VERB = "AND"
         if args.user_like:
             STMT += " "+WHERE_VERB+" user.name LIKE ? "
             ARGS.append(args.user_like)
@@ -205,8 +216,10 @@ def select(args: Namespace):
             WHERE_VERB = "AND"
         for i in db.execute(STMT + " ORDER BY time ASC", ARGS):
             # print(i)
+            username = args.user_overwrite if args.user_overwrite else i[1]
+
             path = os.path.join(i[3],i[4])
-            print('|'.join((str(i[0]),i[1],i[2],path)))
+            print('|'.join((str(i[0]),username,i[2],path)))
 
 def render(args: Namespace):
     print(args)

+ 6 - 42
multigource.sh

@@ -1,45 +1,9 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
 
+SD="$(dirname $0)"
+cd "$SD"
+./multigource.py select log/log.sqlite  --user-regex "(U-AXIT\\\Tobi)|(.*Simets.*)" --user-overwrite "Tobias Simetsreiter"
 
-mkdir -p log
-TOP="$1"
-PREFIX="$2"
-shift 2
 
-containsElement () {
-  local e match="$1"
-  shift
-  for e; do [[ "$e" == "$match" ]] && return 0; done
-  return 1
-}
-
-join_gource(){
-    [ -f log/gource.txt ] || return
-    cat log/gource.txt.gz|gunzip |cat - log/gource.txt |sort -n|uniq|gzip > log/gource.tmp.gz
-    mv log/gource.tmp.gz log/gource.txt.gz
-    rm -f log/gource.txt
-}
-
-join_gource
-
-REPOS_DONE=( $(cat log/repos.done) )
-
-
-find "$TOP" -type d -name '*.git' -print0 | 
-(
-i=0
-while IFS= read -r -d '' line; do 
-    REL="$PREFIX$(realpath --relative-to=$TOP $line)"
-    i="$(( $i + 1 ))"
-
-    containsElement "$REL" "${REPOS_DONE[@]}" && echo "$i $REL is already done" 1>&2
-    containsElement "$REL" "${REPOS_DONE[@]}" && continue;
-
-    echo "Gourcing:$i $REL" 1>&2
-    git -C "$line" log --all --pretty=format:user:%aN%n%ct --reverse --raw --encoding=UTF-8 --no-renames |
-        sed "s, \([ACDMRTU]\)\t, \1\t$REL/," | gource  --log-format git --output-custom-log - -
-    echo "$REL" >> log/repos.done
-done
-) >> log/gource.txt
-
-join_gource
+# export FFMPEG="/c/Users/tobias.simetsreiter/Downloads/ffmpeg-master-latest-win64-gpl-shared/bin/ffmpeg.exe"
+# wsl repos/multigource/multigource.sh | /w/home/tobi/repos/multigource/filtergource.sh /c/Users/tobias.simetsreiter/Downloads/tosi.mkv