erickfmm commited on
Commit
7f11ff0
·
verified ·
1 Parent(s): c9b7823
Files changed (9) hide show
  1. .gitattributes +1 -0
  2. download_files.py +58 -0
  3. log - 1.txt +0 -0
  4. log - 2.txt +0 -0
  5. log - 3.txt +0 -0
  6. log - 4.txt +0 -0
  7. log - 5.txt +0 -0
  8. log.txt +0 -0
  9. metadata.csv +3 -0
.gitattributes CHANGED
@@ -57,3 +57,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ metadata.csv filter=lfs diff=lfs merge=lfs -text
download_files.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import os
3
+ import requests
4
+ from urllib.parse import urlparse, parse_qs
5
+ import time
6
+ import random
7
+
8
+ # Cargar el archivo CSV
9
+ df = pd.read_csv('metadata.csv')
10
+
11
+ # Crear la carpeta donde se guardarán los archivos descargados
12
+ os.makedirs('files', exist_ok=True)
13
+
14
+ ifile = 0
15
+ log = open("log.txt", "w")
16
+ # Recorrer el DataFrame por filas
17
+ for index, row in df.iterrows():
18
+ if row['nombre'] == 'filelink':
19
+ value = row['value']
20
+ if 'isAllowed=y' in value:
21
+ ifile += 1
22
+ print(ifile)
23
+ log.write(str(ifile)+"\n")
24
+ log.flush()
25
+ if ifile < 43310:
26
+ continue
27
+ # Obtener la URL completa agregando el dominio
28
+ file_url = "https://repositorio.uchile.cl" + value
29
+
30
+ try:
31
+ # Parsear la URL para extraer id_coleccion e id_recurso
32
+ parsed_url = urlparse(row['origen'])
33
+ path_parts = parsed_url.path.split('/')
34
+ id_coleccion = path_parts[2]
35
+ id_recurso = path_parts[3]
36
+
37
+ # Obtener el nombre del archivo con su extensión
38
+ file_name = value.split('/')[-1].split('?')[0]
39
+
40
+ # Crear el nombre final del archivo
41
+ final_file_name = f"files/{id_coleccion}_{id_recurso}_{file_name}"
42
+
43
+ #continue
44
+ time.sleep(random.uniform(3,5))
45
+
46
+ # Descargar el archivo
47
+ response = requests.get(file_url)
48
+ if response.status_code == 200:
49
+ with open(final_file_name, 'wb') as f:
50
+ f.write(response.content)
51
+ log.write(f"Archivo descargado: {final_file_name}\n")
52
+ else:
53
+ log.write(f"Error al descargar {final_file_name}: {response.status_code}\n")
54
+ log.flush()
55
+ except:
56
+ log.write("Error")
57
+ log.flush()
58
+ print(ifile)
log - 1.txt ADDED
The diff for this file is too large to render. See raw diff
 
log - 2.txt ADDED
The diff for this file is too large to render. See raw diff
 
log - 3.txt ADDED
The diff for this file is too large to render. See raw diff
 
log - 4.txt ADDED
The diff for this file is too large to render. See raw diff
 
log - 5.txt ADDED
The diff for this file is too large to render. See raw diff
 
log.txt ADDED
The diff for this file is too large to render. See raw diff
 
metadata.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1388886dae6b5964146783f35a13e00c19367415a9fef432cd2869da66968f55
3
+ size 239528961