Giter Site home page Giter Site logo

Fetched images filename bug about laamaj HOT 1 CLOSED

shwoop avatar shwoop commented on June 27, 2024
Fetched images filename bug

from laamaj.

Comments (1)

shwoop avatar shwoop commented on June 27, 2024

The bad files were corrected via:

  1 import sqlite3, subprocess
  2 
  3 dbpath = 'db/laamaj.db'
  4 imgdir = 'db/img/'
  5 
  6 con = sqlite3.connect(dbpath)
  7 cur = con.cursor()
  8 
  9 op = cur.execute("select ws_id, ws_url, ws_localfile from websites where ws_localfile like '%.' order by ws_id desc")
 10 op = [x for x in op]
 11 #op = cur.execute("select ws_id, ws_url, ws_localfile from websites where ws_id = '9455'")
 12 
 13 for key, url, lfile in op:
 14     print key, url, lfile
 15     extension = url.split(u'.')[-1]
 16     newfile = u'%s%s' % (lfile, extension)
 17     cmd = u'mv %s%s %s%s' % (imgdir, lfile, imgdir,  newfile)
 18     retcode = subprocess.call(cmd, shell=True)
 19     if retcode == 0:
 20         script = "update websites set ws_localfile = '%s' where ws_id = '%s'" % (newfile, key)
 21         print script
 22         cur.execute(script)
 23         con.commit()
 24     else:
 25         print 'failed to move'

from laamaj.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.